Type retrieval operator in C#

C# provides a way to produce the reference to the Type object, using the type retrieval operator typeof( ).

It would look like:
typeof(classname);


It will be safer since it’s checked at compile-time.
Because it eliminates the method call, it’s also more efficient.

Example:
using System;
using System.Reflection;

namespace forgetCode
{
    static class ReflectionTest
    {
        public static int Length;
       
        public static void Write()
        {
            //C# checks this at compile time itself

            Type type = typeof(ReflectionTest); // Get type pointer

            FieldInfo[] fields = type.GetFields(); // Obtain all fields
            foreach (var field in fields) // Loop through fields
            {
                string name = field.Name; // Get string name

                object temp = field.GetValue(null); // Get value
                if (temp is int) // See if it is an integer.
                {
                    int value = (int)temp;
                    Console.Write(name);
                    Console.Write(" (int) = ");
                    Console.WriteLine(value);
                }
            }
        }
    }

    class Program
    {
        static void Main()
        {
            ReflectionTest.Length = 100; // Set value
            ReflectionTest.Write(); // Invoke reflection methods
        }
    }

}