Identifying the properties of an object in C#
Identifying the properties of an object in C#:
To identify the properties of the objects in c# we need to use reflection assembly
here we have property info class to get the information of the object of c#
Reflection which allows you to the create dynamic instance of a type or get properties of the existing type and get its methods and properties
Here is the simple example to set and get the value the property of an object
Employee obj=new employee();
string Name="Ram";
PropertyInfo info=obj.GetType().GetProperty("EmpName");
info.SetValue(obj,Convert.ChangeType(Name,info.PropertyType),null);
Hope this will helps you
To identify the properties of the objects in c# we need to use reflection assembly
here we have property info class to get the information of the object of c#
Reflection which allows you to the create dynamic instance of a type or get properties of the existing type and get its methods and properties
Here is the simple example to set and get the value the property of an object
Employee obj=new employee();
string Name="Ram";
PropertyInfo info=obj.GetType().GetProperty("EmpName");
info.SetValue(obj,Convert.ChangeType(Name,info.PropertyType),null);
Hope this will helps you
Labels:
C#