how to get a class with a string in c# code example

Example 1: find class property with string C#

//Add this to class
public class MyClass 
{
    public object this[string property]
    {
        get
        {
            return typeof(security).GetProperty(property).GetValue(this, null);
        }
        set
        {
            typeof(security).GetProperty(property).SetValue(this, value, null);
        }
    }
}

Example 2: c# get class name as string

// in c# 6.0 you can use nameof(ClassName)
// in older versions you may use typeof(ClassName).Name
// example:
public static class ClassName
{
  public static void PrintName => Console.WriteLine(nameof(ClassName));
}