using System;
using System.Collections.Generic;
using System.Linq;
namespace Question1
{
class Program
{
static void Main(string[] args)
{//IEnumerableを実装する
int[] scores = new int[] { 0,-1, -2 };
IEnumerable<int> scoreQuery =//変数の値の範囲を指定
from score in scores
where score > -2
select score;
foreach (int checkpoint in scoreQuery)
{//scoreQueryを列挙
Console.WriteLine("checkpoint" + checkpoint);//変数と文字列の連結表示処理
}
Console.ReadKey();
}
public class hogehoge : Program//継承させてProgramクラスの動作を再利用
{
static void Sub()
{
Console.WriteLine("hogehoge");
Console.ReadKey();
}
}
}
}
More than 5 years have passed since last update.
C#でIEnumerableを実装からのファイルを列挙してデータソースを作る(不足などがあれば指摘お願いします)
Last updated at Posted at 2016-11-20
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme