I heard that C# is a pure object-oriented programming language, because all of things are derived from System.Object
.
So I doubt what's the type of the Method itself. I tried with StackTrace
and StackFrame
to get type of method, but I just got the name of class, which methods are declared.
Of course, I tried this:
var func = new TestClass().TestMethod; //TestMethod is a method of TestClass
however I got only this error.
CS0815 Cannot assign method group to an implicitly-typed variable
Methods can be assigned to Func<..., TResult>
typed variables. I tested with Func and method that returns string, then I got this:
// Result of
// Func<string> func = new TestClass().TestMethod;
// func.GetType();
Instance TestClass -> TestMethod Type : System.Func`1[System.String]
But it's a typename of Func<string>
. So, What's the real typename of methods?
Edit Feb 10, 2018 01:46 AM, KST (GMT +09:00)
Alright, let me summarize. Function itself have no type, also it is not an object, and Delegate
/ Func<>
is a just feature of .NET Framework to handle functions as first class citizen(but it is not an FCC). is it correct?