반응형
SMALL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using static reviewAll01.Earth;
//using static reviewAll01.Earth; // 2022기능으로 알아서 클래스를 가져오더라
namespace reviewAll01
{
class App
{
int[] testSets = { 1, 2, 3, 4, 5, 6, 7 };
List<int> lists = new List<int>();
public App()
{
var testSets1 = from testset in testSets.ToList()
where testset > 5
orderby testset descending
select testset;
foreach (int tesetset in testSets1)
{
Console.WriteLine(tesetset);
}
int num = testSets1.Count();
Console.WriteLine(num);
for(int i = 0; i < 10;i++)
{
lists.Add(num++);
lists.Add(4);
}
var lists1 = from list in lists
where list >= 3
orderby list descending
select list;
Console.WriteLine(lists1.GetType());
foreach (int list in lists1)
{
Console.WriteLine(list);
}
Console.WriteLine();
var testFor = lists1.Distinct().ToList(); // 리스트로 변환과 동시에 중복값 제거도 가능
foreach (int list in testFor) // 4하나만 남기고 모두 제거한 리스트를 출력
{
Console.WriteLine(list);
}
Console.WriteLine();
}
}
}
반응형
LIST
'C# > 개인공부' 카테고리의 다른 글
Func 대리자 & Action 대리자 복습 (0) | 2023.01.15 |
---|---|
변하지 않는 데이터 역직렬화 복습 (0) | 2023.01.15 |
람다식 & 문 복습 (0) | 2023.01.14 |
열거형 복습 (0) | 2023.01.14 |
익명 메서드와 메서드 대리자 호출을 이용하여 이름 나이 출력메서드 만들기 (0) | 2023.01.11 |