What is Fields in ASP.Net C# Programming

A field is a variable of any type that is declared directly in a class or struct. Fields are members of their containing type.

A class or struct may have instance fields or static fields or both. Instance fields are specific to an instance of a type. If you have a class T, with an instance field F, you can create two objects of type T, and modify the value of F in each object without affecting the value in the other object. By contrast, a static field belongs to the class itself, and is shared among all instances of that class.

Fields can be marked as public, private, protected, internal, or protected internal. These access modifiers define how users of the class can access the fields. For more information, see Access Modifiers (C# Programming Guide).

A field can optionally be declared static. This makes the field available to callers at any time, even if no instance of the class exists. For more information, see Static Classes and Static Class Members (C# Programming Guide).

A field can be declared readonly. A read-only field can only be assigned a value during initialization or in a constructor. A static readonly field is very similar to a constant, except that the C# compiler does not have access to the value of a static read-only field at compile time, only at run time. For more information, see Constants (C# Programming Guide).

public class Person
{
public Person()
{
}

#region Property

private int _personID = 0;
public int PersonID
{
get { return _personID; }
set { _personID = value; }
}


private string _firstName = String.Empty;
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}

private string _middleName = String.Empty;
public string MiddleName
{
get { return _middleName; }
set { _middleName = value; }
}

private string _lastName = String.Empty;
public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}

private string _gender = String.Empty;
public string Gender
{
get { return _gender; }
set { _gender = value; }
}

private string _dateofbirth = String.Empty;
public string DateOfBirth
{
get { return _dateofbirth; }
set { _dateofbirth = value; }
}

private string _email = String.Empty;
public string Email
{
get { return _email; }
set { _email = value; }
}

private string _primaryPhone = String.Empty;
public string PrimaryPhone
{
get { return _primaryPhone; }
set { _primaryPhone = value; }
}

private string _mobilePhone = String.Empty;
public string MobilePhone
{
get { return _mobilePhone; }
set { _mobilePhone = value; }
}

private string _address = String.Empty;
public string Address
{
get { return _address; }
set { _address = value; }
}

private string _city = String.Empty;
public string City
{
get { return _city; }
set { _city = value; }
}

private string _state = String.Empty;
public string State
{
get { return _state; }
set { _state = value; }
}

private string _zip = String.Empty;
public string Zip
{
get { return _zip; }
set { _zip = value; }
}

private string _country = String.Empty;
public string Country
{
get { return _country; }
set { _country = value; }
}

private string _personImage = String.Empty;
public string PersonImage
{
get { return _personImage; }
set { _personImage = value; }
}

private int _accountStatus = 0;
public int AccountStatus
{
get { return _accountStatus; }
set { _accountStatus = value; }
}

private string _userName = String.Empty;
public string UserName
{
get { return _userName; }
set { _userName = value; }
}

private string _password = String.Empty;
public string Password
{
get { return _password; }
set { _password = value; }
}

private bool _isActive = false;
public bool IsActive
{
get { return _isActive; }
set { _isActive = value; }
}

private bool _isLock = false;
public bool IsLock
{
get { return _isLock; }
set { _isLock = value; }
}

#endregion
}
Tags: , , , , , , , , , , , , , , , , ,
Hot on Web:


About author