C#C
C#3y ago
arch_il

✅ Convert from string to Type?

public class Foo
{
  public string MyTypeInString = "Foo";
}

public static class SomeFunctions
{
  public static MyFunction<T>(T input)  
  {
    //
  }
}

public class Program
{
  public static void Main()
  {
    Foo f = new();
    SomeFunctions.MyFunction<f.MyTypeInString.ConvertToType()>(f);
  }
}

How do I get that ConvertToType(this string) function? I believe it should be possible.
Was this page helpful?