Ayyappan Anbalagan
Ayyappan Anbalagan

Reputation: 11302

How to maintain my data like a session variable in .NET Windows Forms?

I am using .NET Windows Forms. I need to maintain some date to check the condition. So I have to maintain it until the user logs out.

Like session in ASP.NET.

How can I do this? (Note it should not expire until the user logs out.)

Update:

I create Namespace like this

namespace nsGlobalData {

class GlobalData

{

    public static int GlobalOrgId;

 }

}

To Set:

GlobalData.GlobalOrgId = Convert.ToInt16(ds.Tables[1].Rows[0].ItemArray[0]);

ToGet

txtnamt.text=GlobalData.GlobalOrgId;

Upvotes: 3

Views: 4518

Answers (2)

abatishchev
abatishchev

Reputation: 100308

class Program
{
    internal static Dictionary<string, object> GlobalVariables = new Dictionary<string, object>();

    static void Main(string[] args)
    {
        ...
    }
}

Upvotes: 2

Vilx-
Vilx-

Reputation: 106970

Just use a static variable in some class?

Upvotes: 2

Related Questions