Generic Collection and List : Generic Collections : Generics C# Source Code


Custom Search

C# Source Code » Generics » Generic Collections »

 

Generic Collection and List








    
 
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);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Generics
» Generic Collections