2009年12月9日水曜日

Countを使用しListの要素の個数を数えてみる。
using System;
using System.Collections.Generic;

class MainClass
{
    static void Main()
    {
        // intlistを定義
        var intlist = new List<int> { 1, 2, 3, 4, 5 };

        // 要素の個数を取得
        int a = intlist.Count;

        // 出力値:5
        Console.WriteLine(a);
    }
}

0 コメント:

コメントを投稿