Hi,
Is it possible to overload the default function operator (the () operator) in C#? If so - how? If not, is there a workaround to create a similar affect?
Thanks,
Asaf
EDIT:
I'm trying to give a class a default operator, something along the lines of:
class A {
A(int myvalue) {/*save value*/}
public static int operator() (A a) {return a.val;}
....
}
...
A a = new A(5);
Console.Write(A());
EDIT 2:
I've read the spec and I understand there's no straight forward way to do this. I was hoping there's a workaround.
EDIT 3: The motivation is to make a class, or an instance behave like a function, to make a convenient logging interface. By the way, this is doable and reasonable in C++.