Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

REFLECTION in C#

Reflection is the ability of a computer program to examine and modify the structure and behavior (specifically the fields, meta-data, properties and methods) of an object at runtime.

Example:

using System;
using System.Reflection;

namespace forgetCode
{
   static class ReflectionTest
    {
        public static int Length;
        public static int Width;
        public static int Weight;
        public static string Name;

        public static void Write()
        {
            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);
                }
                else if (temp is string) // See if it is a string.
                {
                    string value = temp as string;
                    Console.Write(name);
                    Console.Write(" (string) = ");
                    Console.WriteLine(value);
                }
            }
        }
    }

    class Program
    {
        static void Main()
        {
            ReflectionTest.Length = 100; // Set value
            ReflectionTest.Width = 50; // Set value
            ReflectionTest.Weight = 300; // Set value
            ReflectionTest.Name = "Forget Code"; // Set value
            ReflectionTest.Write(); // Invoke reflection methods
        }
    }

}

Output:
Length (int) = 100
Width (int) = 50
Weight (int) = 300
Name (string) = Forget Code