This post will explain in simple steps on how to get type name without full name in C# using the typeof operator.
If you want to find the full name of the type in C# , you can use the typeof keyword to do it as shown in the below code snippet.
var str1 = typeof (Author).ToString();
The problem with this method is that it displays the full name along with the namespace.
If you want to get only the class name without namespace , you can use the Name property of MemberInfo class as shown below.
var str2 = typeof(Author).Name; Console.WriteLine("using typeof(Author).Name results in " + str2);
If you are working on C# 6 , you can use the nameof operator to achieve the same as shown below.
var str3 = nameof(Author); Console.WriteLine("using nameof(Author) results in " + str3);