次の方法で共有


DateTime.Year プロパティ (Search)

DateTime の年の構成要素。

構文

public int Year { get; set; }

この例では、News SourceType から、タイトル、説明、および日時の情報を要求し、その情報をコンソール ウィンドウに表示します。下記では、日時の情報を要求するコードと、Year プロパティを返すコードを、太字で示しています。

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.News;
sr[0].ResultFields = ResultFieldMask.Title | ResultFieldMask.Description | ResultFieldMask.DateTime;

searchRequest.Query = "coffee";
searchRequest.Requests = sr;
// Developer Provisioning System で指定されたアプリケーション ID を 二重引用符で囲って 
// SearchRequest の AppID の値として入力します。
searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";
searchRequest.CultureInfo = "en-US";
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.DateTime != null)
            {
                Console.WriteLine("年:" + sourceResult.DateTime.Year.ToString());
Console.WriteLine("月:" + sourceResult.DateTime.Month.ToString());
Console.WriteLine("日:" + sourceResult.DateTime.Day.ToString());
Console.WriteLine("時:" + sourceResult.DateTime.Hour.ToString());
Console.WriteLine("分:" + sourceResult.DateTime.Minute.ToString());
Console.WriteLine("秒:" + sourceResult.DateTime.Second.ToString());
System.DateTime newsDateTime = new System.DateTime(sourceResult.DateTime.Year,
sourceResult.DateTime.Month, sourceResult.DateTime.Day, sourceResult.DateTime.Hour,
sourceResult.DateTime.Minute, sourceResult.DateTime.Second);
// 返された DateTime の日時全体を出力します。
Console.WriteLine("完全な日時:" + newsDateTime.ToString());
            }
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());
}

以下の出力の例は、このクエリの結果を示します。

News - 結果総数: 863618

タイトル:McDonald's switches to eco-friendly coffee in U.K. and Ireland

説明:OAK BROOK, Illinois:Fast food giant McDonald's Corp. announced Monday it would sell only eco-friendly coffee at its 1,200 restaurants in the United Kingdom and Ireland.The Kenco coffee, sold by Kraft Foods Inc., is certified by the conservation ...

年: 2007

月: 1

日: 8

時: 22

分: 11

秒: 52

完全な日時:1/8/2007 10:11:52 PM

*****************************************************

タイトル:Kraft Takes a Charge for a Poor-Selling Coffee Machine

説明:Kraft Foods said yesterday that weaker-than-projected sales of its Tassimo single-serve coffee-brewing machines led to a noncash charge of $245 million in the fourth quarter.The company is writing down the value of the Tassimo production assets and ...

年: 2007

月: 1

日: 9

時: 3

分: 33

秒: 59

完全な日時:1/9/2007 3:33:59 AM

*****************************************************

タイトル:Fort Drum families provide soldiers with war zone coffee shop

説明:FORT DRUM, N.Y. (AP) _ Soldiers serving with a 10th Mountain Division unit in Iraq have their very own coffee shop, thanks to the efforts of family and friends back home at Fort Drum in northern New York.Andrea Aitken came up with the idea as her ...

年: 2007

月: 1

日: 8

時: 18

分: 1

秒: 19

完全な日時:1/8/2007 6:01:19 PM

*****************************************************

タイトル:Caribou Coffee (CBOU) Chairman and Chief Executive Officer to

説明:The opening bell is available from 9:20 a.m. to 9:35 a.m. on uplink IA6 C band / transponder 24, downlink frequency 4180 horizontal.The feed can also be found on Waterfront fiber 1623. If you have any questions, please contact Jolene Libretto at ...

年: 2007

月: 1

日: 8

時: 15

分: 23

秒: 50

完全な日時:1/8/2007 3:23:50 PM

*****************************************************

タイトル:Caribou Coffee Company Plans for Continued Business Expansion,...

説明:-- 4Q 2006 Preliminary Comparable Coffeehouse Net Sales Increase 2 Percent -- Preliminary 2006 Total Net Sales Increase 18 Percent -- 60 Company-Owned and 20 Franchised Coffeehouses Opened in 2006 -- Brand License Agreement with Coca-Cola North ...

年: 2007

月: 1

日: 8

時: 12

分: 53

秒: 31

完全な日時:1/8/2007 12:53:31 PM

*****************************************************

タイトル:Caribou Coffee to offer single-cup brewing packs

説明:Caribou Coffee Co. Inc. and Keurig Inc. announced a partnership Monday to market Caribou's gourmet coffees in single-cup packs for coffee-brewing machines.Under the terms of the arrangement, Brooklyn Center-based Caribou Coffee (Nasdaq:CBOU) will ...

年: 2007

月: 1

日: 9

時: 0

分: 49

秒: 21

完全な日時:1/9/2007 12:49:21 AM

*****************************************************

タイトル:Caribou Coffee plans entry into DIA

説明:Caribou Coffee Co. said Monday it will open a location at Denver International Airport.The Minneapolis-based company (NASDAQ:CBOU) has opened eight locations in the Denver area since moving into the market last year.Frontier Airlines last year ...

年: 2007

月: 1

日: 9

時: 2

分: 0

秒: 56

完全な日時:1/9/2007 2:00:56 AM

*****************************************************

タイトル:In coffee-loving U.S., tea sees surge in sales

説明:SAN FRANCISCO -- In a city saturated with coffeehouses, a state awash in lattes and a nation deeply in love with a cup of joe, they have come for tea.With their heads bent over stainless steel tins of leaves at the Lupicia Fresh Tea boutique here ...

年: 2007

月: 1

日: 8

時: 15

分: 31

秒: 0

完全な日時:1/8/2007 3:31:00 PM

*****************************************************

タイトル:New Coffee May Go Easy On Stomach

説明:The makers of a new type of coffee claim it is sensitive enough for people typically irritated by coffee.The company, Gentle Java , reported that it uses a purification process developed in Europe to remove or reduce impurities and irritants found ...

年: 2007

月: 1

日: 8

時: 22

分: 19

秒: 1

完全な日時:1/8/2007 10:19:01 PM

*****************************************************

タイトル:Coffee Cup owners say they'll reopen

説明:Owners of the Coffee Cup in La Jolla said yesterday they hope to reopen their fire-damaged restaurant within three months.The fire started Thursday night in a storage area at the popular Wall Street eatery, according to the San Diego Fire-Rescue ...

年: 2007

月: 1

日: 8

時: 9

分: 54

秒: 34

完全な日時:1/8/2007 9:54:34 AM

*****************************************************

終了するにはいずれかのキーを押してください。