C#のStringDictionaryからすべてのエントリを削除する
StringDictionaryからすべてのエントリを削除するには、コードは次のとおりです-
例
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
StringDictionary strDict1 = new StringDictionary();
strDict1.Add("A", "John");
strDict1.Add("B", "Andy");
strDict1.Add("C", "Tim");
strDict1.Add("D", "Ryan");
strDict1.Add("E", "Kevin");
strDict1.Add("F", "Katie");
strDict1.Add("G", "Brad");
Console.WriteLine("StringDictionary1 elements...");
foreach(DictionaryEntry d in strDict1){
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("Does StringDictionary1 has key G? "+strDict1.ContainsKey("G"));
StringDictionary strDict2 = new StringDictionary();
strDict2.Add("A", "John");
strDict2.Add("B", "Andy");
strDict2.Add("C", "Tim");
strDict2.Add("D", "Ryan");
strDict2.Add("E", "Kevin");
strDict2.Add("F", "Katie");
strDict2.Add("G", "Brad");
Console.WriteLine("\nStringDictionary2 elements...");
foreach(DictionaryEntry d in strDict2){
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("Count of key/value pairs in StringDictionary2 = " + strDict2.Count);
strDict2.Clear();
Console.WriteLine("Count of key/value pairs in StringDictionary2 (updated) = " + strDict2.Count);
}
} 出力
これにより、次の出力が生成されます-
StringDictionary1 elements... a John b Andy c Tim d Ryan e Kevin f Katie g Brad Does StringDictionary1 has key G? True StringDictionary2 elements... a John b Andy c Tim d Ryan e Kevin f Katie g Brad Count of key/value pairs in StringDictionary2 = 7 Count of key/value pairs in StringDictionary2 (updated) = 0
例
別の例を見てみましょう-
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
StringDictionary strDict = new StringDictionary();
strDict.Add("A", "John");
strDict.Add("B", "Andy");
strDict.Add("C", "Tim");
strDict.Add("D", "Ryan");
Console.WriteLine("StringDictionary elements...");
foreach(DictionaryEntry d in strDict){
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("Count of key/value pairs in StringDictionary = " + strDict.Count);
strDict.Clear();
Console.WriteLine("Count of key/value pairs in StringDictionary (updated) = " + strDict.Count);
}
} 出力
これにより、次の出力が生成されます-
StringDictionary elements... a John b Andy c Tim d Ryan Count of key/value pairs in StringDictionary = 4 Count of key/value pairs in StringDictionary (updated) = 0
-
JavaのArrayListからすべての要素を削除します
JavaでArrayListからすべての要素を削除するには、最初にいくつかの要素を含むArrayListを作成します- ArrayList<Integer> arrlist = new ArrayList<Integer>(5); arrlist.add(25); arrlist.add(50); arrlist.add(75); arrlist.add(100); arrlist.add(150); arrlist.add(200); arrlist.add(250); それでは、すべての要素を削除しましょう- arrlist.clear(); 例 完全なコードを
-
GoogleChromeからのオートフィルエントリの削除
Google Chromeには、保存された情報をフォームに自動的に入力できる機能があります。情報には、URL、ユーザー名、アドレス、パスワード、または任意の支払い情報を使用できます。ユーザーがGoogleChromeの形式で新しい情報を入力すると、その情報を保存するかどうかをユーザーの許可を求めることがあります。ただし、この情報は複数のユーザーには適さない場合があり、一部のユーザーはGoogleChromeからオートフィルエントリを削除したい場合があります。この記事では、GoogleChromeからオートフィル情報を削除/削除できるGoogleChromeの設定を紹介します。 Google