HybridDictionaryエントリをC#の配列インスタンスにコピーする
例
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
HybridDictionary dict = new HybridDictionary();
dict.Add("1", "SUV");
dict.Add("2", "AUV");
dict.Add("3", "Utility Vehicle");
dict.Add("4", "MUV");
dict.Add("5", "Compact Car");
dict.Add("6", "Convertible");
Console.WriteLine("HybridDictionary Key and Value pairs...");
foreach(DictionaryEntry entry in dict){
Console.WriteLine("{0} and {1} ", entry.Key, entry.Value);
}
DictionaryEntry[] dictArr = new DictionaryEntry[10];
Console.WriteLine("\nCopied to Array Instance...");
dict.CopyTo(dictArr, 2);
for (int i = 0; i < dictArr.Length; i++)
Console.WriteLine("Key = "+dictArr[i].Key + ", Value = " + dictArr[i].Value);
}
} 出力
これにより、次の出力が生成されます-
HybridDictionary Key and Value pairs... 1 and SUV 2 and AUV 3 and Utility Vehicle 4 and MUV 5 and Compact Car 6 and Convertible Copied to Array Instance... Key = , Value = Key = , Value = Key = 1, Value = SUV Key = 2, Value = AUV Key = 3, Value = Utility Vehicle Key = 4, Value = MUV Key = 5, Value = Compact Car Key = 6, Value = Convertible Key = , Value = Key = , Value =
例
別の例を見てみましょう-
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
HybridDictionary dict = new HybridDictionary(10);
dict.Add("1", "SUV");
dict.Add("2", "AUV");
dict.Add("3", "Utility Vehicle");
dict.Add("4", "MUV");
Console.WriteLine("HybridDictionary Key and Value pairs...");
foreach(DictionaryEntry entry in dict){
Console.WriteLine("{0} and {1} ", entry.Key, entry.Value);
}
DictionaryEntry[] dictArr = new DictionaryEntry[10];
Console.WriteLine("\nCopied to Array Instance...");
dict.CopyTo(dictArr, 0);
for (int i = 0; i < dictArr.Length; i++)
Console.WriteLine("Key = "+dictArr[i].Key + ", Value = " + dictArr[i].Value);
}
} 出力
これにより、次の出力が生成されます-
HybridDictionary Key and Value pairs... 1 and SUV 2 and AUV 3 and Utility Vehicle 4 and MUV Copied to Array Instance... Key = 1, Value = SUV Key = 2, Value = AUV Key = 3, Value = Utility Vehicle Key = 4, Value = MUV Key = , Value = Key = , Value = Key = , Value = Key = , Value = Key = , Value = Key = , Value =
-
JavaScriptのarray.entries()メソッド。
JavaScriptのarray.entries()メソッドは、キーと値のペアを配列イテレータオブジェクトとして返します。 以下は、array.entries()メソッドのコードです- 例 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /&
-
コマンドキーはどこにありますか?
チュートリアルに従っている場合、または単純なアクションを実行している場合は、Macでコマンドキーを使用する必要がある場合があります。どのキーがどこにあるのか、特にMacキーボードを使用していない場合は、適切な場所に来ました。 コマンドキーとは何ですか? CommandキーまたはCmdキー(Appleキーと呼ばれることもあります)は、Macキーボードで最も便利なキーの1つです。 コマンドキーは、Macの最も一般的なアクションの多くで1文字のキーとともに使用されます。コピーするにはCommand-C、印刷にはCommand-P、貼り付けにはCommand-Vなどです。 その機能はPCキーボー