Machineboy空

C# Generic Types 본문

언어/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

 

'언어 > C#' 카테고리의 다른 글

C# 정수형 (Integral Number)  (0) 2025.02.03
C# 상속, 다형성(Polymolphism)  (0) 2025.02.03
LINQ  (0) 2025.01.23
Visual Studio 기본 환경 세팅  (0) 2025.01.23
C# Class: static Field 정적 필드, 클래스와 인스턴스  (0) 2025.01.20