Database Reference
In-Depth Information
public string ZipCode
{
[SqlMethod(IsDeterministic = true, IsPrecise = true)]
get { return _zipCode; }
}
public override string ToString()
{
return String.Format("{0}, {1}, {2}, {3}", _address, _city, _state, _zipCode);
}
// The static representation of Null object
public static USPostalAddress Null
{
get
{
USPostalAddress h = new USPostalAddress();
h._null = true;
return h;
}
}
// Validation that Address information is correct
private bool ValidateAddress()
{
// Check that all attributes are specified and state is valid
return
!(
String.IsNullOrEmpty(_address) ||
String.IsNullOrEmpty(_city) ||
String.IsNullOrEmpty(_state) ||
String.IsNullOrEmpty(_zipCode) ||
_validStates.BinarySearch(_state.ToUpper()) == -1
);
}
// Creating object from the string
public static USPostalAddress Parse(SqlString s)
{
if (s.IsNull)
return Null;
USPostalAddress u = new USPostalAddress();
string[] parts = s.Value.Split(",".ToCharArray());
if (parts.Length != 4)
throw new ArgumentException("The value has incorrect format. Should be <Address>,
<City>, <State>, <ZipCode>");
u._address = parts[0].Trim();
u._city = parts[1].Trim();
u._state = parts[2].Trim();
u._zipCode = parts[3].Trim();
 
Search WWH ::




Custom Search