... | @@ -223,7 +223,7 @@ ar.Add(n); |
... | @@ -223,7 +223,7 @@ ar.Add(n); |
|
ArrayList는 모든 타입의 collection을 구성할 수 있도록 만들어졌기 때문에 Add method는 prameter로 object type을 받는다. int는 value type이고 object reference type이므로 int 5는 boxing되 heap에 object instance를 할당하고 그 참조 개체가 ArrayList의 Add method에 전달된다.
|
|
ArrayList는 모든 타입의 collection을 구성할 수 있도록 만들어졌기 때문에 Add method는 prameter로 object type을 받는다. int는 value type이고 object reference type이므로 int 5는 boxing되 heap에 object instance를 할당하고 그 참조 개체가 ArrayList의 Add method에 전달된다.
|
|
<img src="ThirdImage/boxing_arraylist.png" width="350">
|
|
<img src="ThirdImage/boxing_arraylist.png" width="350">
|
|
|
|
|
|
이 문제를 해결하기 위해 닷넷 프레임워크 2.0에서는 generic이 도입된 새로운 collection type인 'List< T>'타입이 발표됐고 아래 예제와 같이 사용한다.
|
|
이 문제를 해결하기 위해 닷넷 프레임워크 2.0에서는 generic이 도입된 새로운 collection type인 `List<T>`타입이 발표됐고 아래 예제와 같이 사용한다.
|
|
``` cs
|
|
``` cs
|
|
public class GenericList<T>
|
|
public class GenericList<T>
|
|
{
|
|
{
|
... | | ... | |