If I have a class called sample, is there a way(Common) of retrieving "sample" as a string?
- public class sample
- {
- public int MyProperty { get; set; }
- public int MyProperty2 { get; set; }
- public string MyProperty3 { get; set; }
- }
- sample sampleClass = new sample();
- List
sampleClassList = new List (); - var name = sampleClass.GetType().Name;
- var name2 = sampleClassList.GetType().Name;
In here class object class name correct but list object not get. is there any common way to get class name of object (List and Class)
Guest UserPosted Aug 12, 2020, 6:34 AM
Kunjahamed PPosted Aug 12, 2020, 7:28 AM
Pankajkumar PatelPosted Aug 12, 2020, 6:47 AM
GetType()which provides the properSystem.Typeof the object at runtime as like following: