Information Technology Reference
In-Depth Information
get
;
set
;
}
public string
City
{
get
;
set
;
}
public string
State
{
get
{
return
state; }
set
{
ValidateState(
value
);
state =
value
;
}
}
public int
ZipCode
{
get
{
return
zipCode; }
set
{
ValidateZip(
value
);
zipCode =
value
;
}
}
// other details omitted.
}
// Example usage:
Address
a1 =
new
Address
();
a1.Line1 =
"111 S. Main"
;
a1.City =
"Anytown"
;
a1.State =
"IL"
;
a1.ZipCode =
61111
;
// Modify:
a1.City =
"Ann Arbor"
;
// Zip, State invalid now.
a1.ZipCode =
48103
;
// State still invalid now.
a1.State =
"MI"
;
// Now fine.