[C#] LINQ์์ foreach๋ฅผ ์ฌ๋ฌ ๋ฒ ์ฐ๋ฉด ์๋๋ ์ด์
LINQ์ foreach var list = new List { new Profile() { Name = "A", Age = 1 }, new Profile() { Name = "B", Age = 2 }, new Profile() { Name = "C", Age = 3 }, new Profile() { Name = "D", Age = 4 }, new Profile() { Name = "E", Age = 5 }, new Profile() { Name = "F", Age = 3 }, }; var a = list.Where(profile => profile.Age > 1); if (a.Any()) { foreach (var profile in a) { Console.WriteLine(profile.Name); ..
2023. 10. 12.
[C#] LINQ์ Single()์ ๋ํด์
Single() single์ ์ปฌ๋ ์
์์ ์ ์ผํ ์์๋ฅผ ๋ฐํํ๋ค. var list = new List { new Profile() { Name = "A", Age = 1 }, new Profile() { Name = "B", Age = 2 }, new Profile() { Name = "C", Age = 3 }, new Profile() { Name = "D", Age = 4 }, new Profile() { Name = "E", Age = 5 }, new Profile() { Name = "F", Age = 6 } }; var singleList = list.Single(x => x.Age == 3); Console.WriteLine(singleList.ToString()); ์ list์์ Age๊ฐ ..
2023. 10. 12.
");
wcs_do();