Tuesday, 1 June 2021

Screen Capture in C#

using System;

using System.Drawing;

using System.Drawing.Imaging;

using System.Threading;


 

int i = 0;

            do

            {

                i++;

                Bitmap bitmap = new Bitmap(1920, 1080);

                Graphics graphics = Graphics.FromImage(bitmap as Image);

                graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

                Random rnd = new Random();

                int rndNumber = rnd.Next(1, 10000);

                //var n1 = i + rndNumber;

                var ImgName = $"{i}_{rndNumber}_test";

                bitmap.Save($"E:\\FreeSoftwareTraining\\ScreenImg\\{ImgName}.jpeg", ImageFormat.Jpeg);

                Thread.Sleep(30000);

            }

            while (true);

Thursday, 27 May 2021

Basic Generic class and method

 public class TestList<T>

{

    public void Add(T input) { }

}

class TestGList

{

    private class Example1 { }

    static void Main()

    {

        // Declare a list of type int.

        TestList<int> list1 = new TestList<int>();

        list1.Add(1);


        // Declare a list of type string.

        TestList<string> list2 = new TestList<string>();

        list2.Add("");


        // Declare a list of type Example1.

        TestList<Example1> list3 = new TestList<Example1>();

        list3.Add(new Example1());

    }

}