Skip to content

Address

Record public
Represents a physical or mailing address, decomposed into street, city, state, postal code, and country components.
Namespace SampleApi
Assembly SampleApi
Package v1.0.0.0
public record Address
: System.IEquatable<SampleApi.Address>
IEquatable<Address>
Implements
IEquatable<Address>
classDiagram
    direction TB
    class Address {
        <<record>>
    }
    class IEquatable~Address~ {
        <<interface>>
    }
    IEquatable~Address~ <|.. Address
Address is a record class providing value-based equality and immutability by default, making it suitable for use as an embedded value object within aggregate roots such as Customer. The Country field uses ISO 3166-1 alpha-2 codes rather than full country names to ensure consistent, locale-independent storage.
Address.Address(
string Street,
string City,
string State,
string PostalCode,
string Country)

Represents a physical or mailing address, decomposed into street, city, state, postal code, and country components.

Street string
The street address, including house or building number (e.g., "123 Main St").
City string
The city or locality name (e.g., "Seattle").
State string
The state, province, or region (e.g., "WA").
PostalCode string
The postal or ZIP code (e.g., "98101").
Country string
The ISO 3166-1 alpha-2 country code (e.g., "US", "DE").
Address is a record class providing value-based equality and immutability by default, making it suitable for use as an embedded value object within aggregate roots such as Customer. The Country field uses ISO 3166-1 alpha-2 codes rather than full country names to ensure consistent, locale-independent storage.

Creating an address for a US location:

var address = new Address(
Street: "One Microsoft Way",
City: "Redmond",
State: "WA",
PostalCode: "98052",
Country: "US"
);
string Address.City

The city or locality name (e.g., "Seattle").

string Address.Country

The ISO 3166-1 alpha-2 country code (e.g., "US", "DE").

string
string Address.PostalCode

The postal or ZIP code (e.g., "98101").

string Address.State

The state, province, or region (e.g., "WA").

string Address.Street

The street address, including house or building number (e.g., "123 Main St").

Creating an address for a US location:

var address = new Address(
Street: "One Microsoft Way",
City: "Redmond",
State: "WA",
PostalCode: "98052",
Country: "US"
);