How can I create a method in C# that behaves like the String.ToString ()?
I know (or at least I think I do) need to extend or create a new class, but I don't know how to retrieve the object value before the .ToString().
Something like I used to do in ActionScripts a few years ago...
Then I'd use just like... myClip.MyFuncti on();
Im trying to achieve the same result in C# (2.0) but haven't got any good results here.
It should looks like this:
The I could use it like
Any help is welcome, since I tried to google about it, but I dont know who exatcly this kind of method is called.
Ricardo
I know (or at least I think I do) need to extend or create a new class, but I don't know how to retrieve the object value before the .ToString().
Something like I used to do in ActionScripts a few years ago...
Code:
MovieClip.prototype.MyFunction(){
trace (this.name);
}
Im trying to achieve the same result in C# (2.0) but haven't got any good results here.
It should looks like this:
Code:
public string Add1() {
// method constructor here;
}
Code:
string aVar = "word"; string result = aVar.Add1(); // resulting "word1"
Ricardo
Comment