Reputation: 1
I think the easiest way to explain my problem is with an example.
class MyClass
{
string SomeFunction()
{
//magic
}
}
Void Main
{
MyClass test = new MyClass();
Console.WriteLine( SomeFunction );
}
So the thing I want “SomeFunktion” to is to give back the name of MyClass. In this case it would be “test”.
Is it even possible?
Upvotes: 0
Views: 60
Reputation: 48558
BTW it should be Console.WriteLine(test.SomeFunction());
and
No you cannot do that unless you are using C# 6.
In C# 6, you have an operator nameof where you can pass instance and it returns name of instance like in your case "test" like nameof(test)
and it would return "test".
Upvotes: 4