Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#에서 대소문자를 구분하는 빈 HybridDictionary 클래스 만들기

<시간/>

대소문자를 구분하는 빈 HybridDictionary를 생성하기 위한 코드는 다음과 같습니다 -

using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
   public static void Main() {
      HybridDictionary dict = new HybridDictionary(false);
      dict.Add("A", "AB");
      dict.Add("B", "BC");
      dict.Add("C", "DE");
      dict.Add("D", "de");
      Console.WriteLine("Key/Value pairs...");
      foreach(DictionaryEntry de in dict)
         Console.WriteLine("Key = "+de.Key + ", Value = " + de.Value);
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Key/Value pairs...
Key = A, Value = AB
Key = B, Value = BC
Key = C, Value = DE
Key = D, Value = de

다른 예를 살펴보겠습니다 -

using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
   public static void Main() {
      HybridDictionary dict = new HybridDictionary(true);
      dict.Add("A", "AB");
      dict.Add("B", "BC");
      dict.Add("C", "DE");
      dict.Add("D", "de");
      dict.Add("e", "FG");
      dict.Add("F", "gh");
      Console.WriteLine("Key/Value pairs...");
      foreach(DictionaryEntry de in dict)
      Console.WriteLine("Key = "+de.Key + ", Value = " + de.Value);
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Key/Value pairs...
Key = A, Value = AB
Key = B, Value = BC
Key = C, Value = DE
Key = D, Value = de
Key = e, Value = FG
Key = F, Value = gh