Tag: Type

How to Format a Type with ToString () in C#?

The ToString method of a type will show the type’s name. For example , If the Object is the Employee type , then calling the ToString will display the Type Name along with the name space as shown in the below screenshot. You can override the ToString method to provide you own way to display the data when ToString is called. How to Format a…

How to Get the Name of the Anonymous class(type) in C# ?

Below is a sample code snippet which gets the name of the anonymous class . In the below example , the Name and the ID property is set which is anonymous where the type is not specified. When trying to find out the type of the anonymous type , you will get the type as shown in the screenshot below. How to Get the Name…