Generic List 복제하는 방법

Category:
Author: zemna
Date: April 17, 2021
Share this:

클래스에서 Copy() 나 Clone() 함수를 제공하지 않아 For 문을 이용해서 대입해야 하는 줄 알았다... 😥

[code lang="csharp"]

// Generic List 생성 List a = new List();

// 값 추가하기 a.Add(1); a.Add(2); a.Add(3);

// List 복제하기 List b = new List(a); [/code]

위의 코드와 같이 생성할 List 템플릿의 생성자에 복제할 List 클래스의 인스턴스를 넘겨주면 복제가 된다.

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram