[C#]IEnumerableインターフェースの要素を取得する

2022年1月4日

書式
IEnumerable<double> コレクション名 = new[] { 要素1, 要素2,xxx };
foreach(var 変数名 in コレクション名 )
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
using System;
using System.Collections.Generic;
namespace infoapp
{
class Program
{
static void Main(string[] args)
{
IEnumerable<double> cft = new[] { 3.03, 4.14, 5.25, 6.36, 7.47 };
foreach (var val in cft)
{
Console.Write(val + ", ");
}
Console.ReadKey();
}
}
}
using System; using System.Collections.Generic; namespace infoapp { class Program { static void Main(string[] args) { IEnumerable<double> cft = new[] { 3.03, 4.14, 5.25, 6.36, 7.47 }; foreach (var val in cft) { Console.Write(val + ", "); } Console.ReadKey(); } } }
using System;
using System.Collections.Generic;
 
namespace infoapp
{
    class Program
    {
        static void Main(string[] args)
        {
 
            IEnumerable<double> cft = new[] { 3.03, 4.14, 5.25, 6.36, 7.47 };
 
            foreach (var val in cft)
            {
                Console.Write(val + ", "); 
            }
 
            Console.ReadKey();
 
        }
    }
}

実行結果
3.03, 4.14, 5.25, 6.36, 7.47,

C#

Posted by arkgame