Using this
coding, we can maintain a value throughout the application and access that
value in any form of the application.
Example:
Declare
and Define Value:
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace Example
{
public class MaintainValue
{
//User Name
public static string strUserName;
public static string UserName
{
get
{
return strUserName;
}
set
{
strUserName = value;
}
}
//Pass Word
public static string strPassword;
public static string Password
{
get
{
return strPassword;
}
set
{
strPassword = value;
}
}
}
}
Access
the value:
//Calls the
UserName Method of class MaintainValue and assign it to the label.
lblusername.Text =
MaintainValue.UserName;