Generic Collection and List

image_pdfimage_print
   
  
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

public class CollectionTest {
    public static void Main() {
        Collection<int> intCollection = new Collection<int>();

        List<String> strList = new List<String>();
        strList.Add("Val1");
        strList.Add("Val2");

        Collection<String> strCollection = new Collection<String>(strList);

        foreach (String strVal1 in strCollection)
            System.Console.WriteLine(strVal1);

        strList[0] = "Val Changed";

        foreach (String strVal2 in strCollection)
            System.Console.WriteLine(strVal2);
    }
}

   
     


This entry was posted in Generics. Bookmark the permalink.