[C#]IEnumerableインターフェースの要素を取得する
書式
IEnumerable<double> コレクション名 = new[] { 要素1, 要素2,xxx };
foreach(var 変数名 in コレクション名 )
使用例
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,