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
Post a Comment