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>
-
C#のコンソールクラス
C#のConsoleクラスは、コンソールアプリケーションの標準の入力、出力、およびエラーストリームを表すために使用されます。 C#のコンソールクラスプロパティの例をいくつか見てみましょう- Console.CursorLeftプロパティ C#でコンソールのCursorLeftを変更するには、Console.CursorLeftプロパティを使用します。 例 例を見てみましょう- using System; class Demo { public static void Main (string[] args) { Cons
-
Pythonでクラスを作成する
クラス ステートメントは、新しいクラス定義を作成します。クラスの名前は、次のようにキーワードclassの直後にコロンが続きます- class ClassName: 'Optional class documentation string' class_suite クラスにはドキュメント文字列があり、ClassName .__doc__からアクセスできます。 class_suiteは、クラスメンバー、データ属性、および関数を定義するすべてのコンポーネントステートメントで構成されています。 例 以下は、単純なPythonクラスの例です- class Employee: &n