What is the right way to take screenshots using C#? It’s certainly possible to grab a screenshot using the .NET Framework. The following code snippet provides a C# class for capturing and saving screenshots. public class Screenshot { public DateTime timestamp; public Bitmap bitmap; public Screenshot(DateTime timestamp, Bitmap bitmap) { this.timestamp = timestamp; this.bitmap = bitmap; } }...
Calling a method from a string in C# (dynamic method invocation)
We are often used to call methods dynamically. You can invoke methods of a class instance using reflection, doing a dynamic method invocation. The following code snipped presents an easy way of invocation in C#. public void Execute(string methodName, object[] args) { if (GetType().GetMethod(methodName)) != null) { MethodInfo method = GetType().GetMethod(methodName); method.Invoke(this, new...