How to create extension methods for Types

To use the extension method, you would have to do:

var instance = typeof(MyClass).ParseJson(text);

The token "MyClass" is not a Type instamce intself, but using typeof will get you a Type to operate on. But how is this any better than:

var instance = JsonUtility.ParseJson<MyClass>(text);

Edit: Actually, the code for the extension method still would not do what you wanted. It will always return a "Type" object, not an instance of that Type.


The short answer is it cannot be done; extension methods need to work on an instance of something.