I am writing an extension method for parsing JSON string for any given type. I wanted to use the method on types instead of instances like many examples we already know, but
As stated in the accepted answer, you can't. However, provided that you have an extension method that can be called from an instance of T:
public static T ParseJson(this T t, string s)
You could write a utility method like this:
public static T ParseJson(string s)
where T: new()
=> new(T).ParseJson(s);
And call it like this:
var t = Utilities.ParseJson(s);
I am afraid that's the best you can do...