Use a Strongly Typed Collection - CSharp Collection

CSharp examples for Collection:Dictionary

Description

Use a Strongly Typed Collection

Demo Code

using System;/*from   www . ja  va2s.  c  om*/
using System.Reflection;
using System.Collections.Generic;
class MainClass
{
   public static void Main(string[] args)
   {
      AssemblyName assembly1 = new AssemblyName("com.microsoft.crypto, " + "Culture=en, PublicKeyToken=a5d015c7d5a0b012, Version=1.0.0.0");
      Dictionary<string,AssemblyName> assemblyDictionary = new Dictionary<string,AssemblyName>();
      assemblyDictionary.Add("Crypto", assembly1);
      AssemblyName a1 = assemblyDictionary["Crypto"];
      Console.WriteLine("Got AssemblyName from dictionary: {0}", a1);
      List<AssemblyName> assemblyList = new List<AssemblyName>();
      assemblyList.Add(assembly1);
      AssemblyName a2 = assemblyList[0];
      Console.WriteLine("\nFound AssemblyName in list: {0}", a1);
      Stack<AssemblyName> assemblyStack = new Stack<AssemblyName>();
      assemblyStack.Push(assembly1);
      AssemblyName a3 = assemblyStack.Pop();
      Console.WriteLine("\nPopped AssemblyName from stack: {0}", a1);
   }
}

Result


Related Tutorials