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 UserRank #816 · 2.8K reputationPosted Aug 12, 2020, 2:34 AM EDT
Pankajkumar PatelRank #181 · 13.4K reputationPosted Aug 12, 2020, 2:47 AM EDT
GetType()which provides the properSystem.Typeof the object at runtime as like following:Kunjahamed PRank #5,790 · 286 reputationPosted Aug 12, 2020, 3:28 AM EDT