Address.PostalCode プロパティ (Search)
サポートされている場所の住所の郵便番号を示します。
構文
public string PostalCode { get; set; }
解説
次の住所の太字部分が、PostalCode です。
22 Fleet St, London, GB, EC4Y 1AA
注意
米国で使用されているような ZIP コードは、返されません。
例
この例では、PhoneBook SourceType から、タイトル、説明、および住所の情報を要求し、その情報をコンソール ウィンドウに表示します。下記では、住所の情報を要求するコードと、PostalCode プロパティを返すコードを、太字で示しています。
try
{
MSNSearchService s = new MSNSearchService();
SearchRequest searchRequest = new SearchRequest();
int arraySize = 1;
SourceRequest[] sr = new SourceRequest[arraySize];
sr[0] = new SourceRequest();
sr[0].Source = SourceType.PhoneBook;
sr[0].ResultFields = ResultFieldMask.Title | ResultFieldMask.Description | ResultFieldMask.Address;
searchRequest.Query = "umbrella";
searchRequest.Requests = sr;
// Developer Provisioning System で指定されたアプリケーション ID を 二重引用符で囲って
// SearchRequest の AppID の値として入力します。
searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";
searchRequest.CultureInfo = "en-GB";
// Locaiton を英国の London の中央に設定し、既定の半径値、5.0 マイルを使用します。
// 緯度と経度に 10 進数値を使用して、Location を変更し、サポートされている他の場所の住所を返すことができます。
searchRequest.Location = new Location();
double latitude = 51.5063;
double longitude = -0.127099;
searchRequest.Location.Latitude = latitude;
searchRequest.Location.Longitude = longitude;
SearchResponse searchResponse;
searchResponse = s.Search(searchRequest);
foreach (SourceResponse sourceResponse in searchResponse.Responses)
{
Result[] sourceResults = sourceResponse.Results;
if (searchResponse.Responses[0].Total > 0)
{
Console.WriteLine(sourceResponse.Source.ToString() + " - 結果総数:" + sourceResponse.Total.ToString());
Console.WriteLine();
}
foreach (Result sourceResult in sourceResults)
{
if ((sourceResult.Title != null) && (sourceResult.Title != String.Empty))
Console.WriteLine("タイトル:" + sourceResult.Title);
if ((sourceResult.Description != null) && (sourceResult.Description != String.Empty))
Console.WriteLine("説明:" + sourceResult.Description);
if (sourceResult.Address != null)
{
if ((sourceResult.Address.AddressLine != null) && (sourceResult.Address.AddressLine != String.Empty))
Console.WriteLine("番地:" + sourceResult.Address.AddressLine);
if ((sourceResult.Address.CountryRegion != null) && (sourceResult.Address.CountryRegion != String.Empty))
Console.WriteLine("国/地域:" + sourceResult.Address.CountryRegion);
if ((sourceResult.Address.PostalCode != null) && (sourceResult.Address.PostalCode != String.Empty))
Console.WriteLine("郵便番号:" + sourceResult.Address.PostalCode);
if ((sourceResult.Address.PrimaryCity != null) && (sourceResult.Address.PrimaryCity != String.Empty))
Console.WriteLine("都市:" + sourceResult.Address.PrimaryCity);
if ((sourceResult.Address.SecondaryCity != null) && (sourceResult.Address.SecondaryCity != String.Empty))
Console.WriteLine("第二都市:" + sourceResult.Address.SecondaryCity);
}
Console.WriteLine("*****************************************************");
}
Console.WriteLine("終了するにはいずれかのキーを押してください。");
Console.ReadLine();
}
}
catch (SoapException fault)
{
Console.WriteLine(fault.Detail.InnerText.ToString());
Console.WriteLine("終了するにはいずれかのキーを押してください。");
Console.ReadLine();
}
catch (WebException webx)
{
Console.WriteLine(webx.ToString());
}
コメント
以下の出力の例は、このクエリの結果を示します。
PhoneBook - 結果総数: 14
タイトル:Umbrella
説明:020 7637 3390 - Office 12,39 Riding House St, London, W1W 7BE
番地:Office 12,39 Riding House St
国/地域:GB
郵便番号:W1W 7BE
都市:London
*****************************************************
タイトル:Green Umbrella Entertainment
説明:020 7379 7246 - 3 Nottingham Ct, London, WC2H 9AY
番地:3 Nottingham Ct
国/地域:GB
郵便番号:WC2H 9AY
都市:London
*****************************************************
タイトル:James Smith & Sons Ltd
説明:020 7836 4731 - 53 New Oxford St, London, WC1A 1BL
番地:53 New Oxford St
国/地域:GB
郵便番号:WC1A 1BL
都市:London
*****************************************************
タイトル:Umbrella
説明:020 7388 4137 - Mary Wollstonecraft House,99 Chalton St, London,
NW1 1SP
番地:Mary Wollstonecraft House,99 Chalton St
国/地域:GB
郵便番号:NW1 1SP
都市:London
*****************************************************
タイトル:Umbrella
説明:020 7383 5710 - 2 Hurdwick Pl, London, NW1 2JE
番地:2 Hurdwick Pl
国/地域:GB
郵便番号:NW1 2JE
都市:London
*****************************************************
タイトル:Film & Video Umbrella Ltd
説明:020 7407 7755 - 52 Bermondsey St, London, SE1 3UD
番地:52 Bermondsey St
国/地域:GB
郵便番号:SE1 3UD
都市:London
*****************************************************
タイトル:Umbrella Design
説明:020 7833 4032 - 335 City Rd, London, EC1V 1LJ
番地:335 City Rd
国/地域:GB
郵便番号:EC1V 1LJ
都市:London
*****************************************************
タイトル:Umbrella
説明:020 7359 5385 - 61 Islington Pk St, London, N1 1QB
番地:61 Islington Pk St
国/地域:GB
郵便番号:N1 1QB
都市:London
*****************************************************
タイトル:Umbrella
説明:020 7431 3634 - 180 Haverstock Hill,Belsize Park, London, NW3 2AL
番地:180 Haverstock Hill,Belsize Park
国/地域:GB
郵便番号:NW3 2AL
都市:London
*****************************************************
タイトル:Umbrella Handyperson Service
説明:020 7354 9204 - Unit HG02,Aberdeen Centre,24 Highbury Gr, London,
N5 2EA
番地:Unit HG02,Aberdeen Centre,24 Highbury Gr
国/地域:GB
郵便番号:N5 2EA
都市:London
*****************************************************
終了するにはいずれかのキーを押してください。
関連項目
参照
SearchRequest.Location プロパティ (Search)
Result.Address プロパティ (Search)
Result.Location プロパティ (Search)
Address クラス (Search)
Location クラス (Search)