c# generic function - an extension of another generic -


here's typical example of generic method in c#:

parseobject po;  int = po.get<int>("somefield"); string s = po.get<string>("anotherfield"); 

i want write extension work ...

 int = po.exampleget<int>("somefield");  string = po.exampleget<string>("anotherfield"); 

so,

(a) extension exampleget have able accept < class > in same way parseobject.get does, and

(b) extension exampleget have able call parseobject.get (as doing other work).

what's syntax such n extension, uses generic in way ?

possibly looking extension methods:

static public class extensions {   static t exampleget<t>(this parseobject po, string name)   {       return po.get<t>(name);   } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -