LoginSignup
0
0

More than 5 years have passed since last update.

【c#】Dictionaryを使い日付と体重データを保持する例

Posted at

using System;
//以下の名前空間を追加
using System.Collections.Generic;

namespace dictionary_weights
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            // Dictionaryを使い日付と体重データを保持する例

            // 1. Dictionary型の変数を作る
            Dictionary<string, float> weights = new Dictionary<string, float>();

            // 2. Dictionaryに要素を追加
            weights.Add("2017/12/10", 62.6f);
            weights.Add("2017/12/11", 21.9f);
            weights.Add("2017/12/12", 41.8f);
            weights.Add("2017/12/13", 62.1f);
            weights.Add("2017/12/14", 42.7f);
            weights.Add("2017/12/15", 82.1f);
            weights.Add("2017/12/16", 63.8f);
            weights.Add("2017/12/17", 23.8f);

            // 3. 2017/12/13の体重を表示
            Console.WriteLine(weights["2017/12/13"]);
        }
    }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0