언어/C#

C# Generic Types

안녕도라 2025. 1. 24. 18:52

Generic Type이란?

<T> allows the collection user to specify what type of items to store in the collection

어떤 타입의 아이템을 저장할지 사용자가 지정할 수 있는 컬렉션.

 

예) List<T> : T is the type of the item in the list

var listOfString = new List<String>();

 

https://machineboy0.tistory.com/48

 

괄호들: Generic [ ], ( ), { }, < >

정적인 언어들에서 흔히 쓰이는 Generic 정의 사용 예시 Generics - 클래스 내부에서 지정하는 것이 아닌 외부에서 사용자에 의해 지정하는 것 - 특정(specific)타입을 미리 지정하는 것이 아닌 필요에

machineboy0.tistory.com


List 기본 메소드

  • Add()
  • Contains()
  • Reverse()
  • RemoveAt()
  • Find()
  • Distinct()

https://exercism.org/tracks/csharp/exercises/tracks-on-tracks-on-tracks/solutions/stevenyholm