ก็สร้างเป็น static class อะครับคือสร้างคลาสขึ้นมาใหม่
มีชนิดเป็น static ตัวอย่างเช่น
static class Test
{
private static string str = "";
public static string GlobalVariable
{
get { return str; }
set { str = value; }
}
}
หลังจากนั้นต้องการเก็บค่าไหนก็สามารถเขียนได้ดังนี้
Test.GlobalVariable = "ค่าที่ต้องการ";
แล้วถ้าต้องการเอาค่านี้ไปใช้ที่ไหนก็เขียนได้ดังนี้ เช่นนำไปใส่ไว้ใน Label
Label1.Text = Test.GlobalVariable;
[With great power comes great responsibility]