Date: 2010-01-15 03:00 am (UTC)
In C# we have extension methods - special static methods declared separately, but used as regular methods, pretty much like prototype methods in javascript.


public class MyClass {}

// declaration
public static class Ex
{
  public static string toJson<T>(this T obj) { /* serialize to json */ }
}

...

//usage
var myobj = new MyClass();
myobj.toJson();
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 3rd, 2025 04:02 pm
Powered by Dreamwidth Studios