C# accessing a property of a generic class T -


i need accessing property of generic class t have method in class generic

 public t calcuste(t obj)  {       calcaulte testobj= new calcaulte ()       var t = getvalue(obj); // type of class example calcaulte class         testobj.id = obj.id;// need accessing  property of t obj   } 

try following code.

public t calcuste(t obj) {     calcaulte testobj= new calcaulte ();     calcaulte obj_calcaulte  = obj calcaulte;     if(obj_calcaulte  != null)     {         testobj.id = obj_calcaulte  .id;        }  }    

you need control null since obj may null or may belong different class.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -