how to create a global variable in c# code example

Example 1: how to make a global string c#

public static class Globals
{
    public const Int32 BUFFER_SIZE = 512; // Unmodifiable
    public static String FILE_NAME = "Output.txt"; // Modifiable
    public static readonly String CODE_PREFIX = "US-"; // Unmodifiable
}

String code = Globals.CODE_PREFIX + value.ToString();

Example 2: how to make a global variable in c#

Make A New Class File And Add This

    internal class Global
    {
        public static int32 Int1 = 1;
        public static string Text1 = "Sample Text";
		public static bool Bool1 = True;
    }