Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> C#

C# में जांचें कि ListDictionary सिंक्रनाइज़्ड है या नहीं

उदाहरण

ListDictionary की IsSynchronized प्रॉपर्टी बताती है कि डिक्शनरी थ्रेड-सेफ (सिंक्रनाइज़्ड) है या नहीं। यह प्रॉपर्टी हमेशा false लौटाती है क्योंकि ListDictionary सिंक्रनाइज़्ड नहीं होती।

using System;
using System.Collections;
using System.Collections.Specialized;

public class Demo {
    public static void Main() {
        ListDictionary dict = new ListDictionary();
        dict.Add("1", "SUV");
        dict.Add("2", "Sedan");
        dict.Add("3", "Utility Vehicle");
        dict.Add("4", "Compact Car");
        dict.Add("5", "SUV");
        dict.Add("6", "Sedan");
        dict.Add("7", "Utility Vehicle");
        dict.Add("8", "Compact Car");
        dict.Add("9", "Crossover");
        dict.Add("10", "Electric Car");

        Console.WriteLine("ListDictionary तत्व...");
        foreach(DictionaryEntry d in dict) {
            Console.WriteLine(d.Key + " " + d.Value);
        }

        Console.WriteLine("\nक्या ListDictionary का आकार निश्चित है? = " + dict.IsFixedSize);
        Console.WriteLine("क्या ListDictionary रीड-ओनली है? = " + dict.IsReadOnly);
        Console.WriteLine("क्या ListDictionary सिंक्रनाइज़्ड है? = " + dict.IsSynchronized);
        Console.WriteLine("क्या ListDictionary में कुंजी K है? = " + dict.Contains("K"));
        Console.WriteLine("क्या ListDictionary में कुंजी 9 है? = " + dict.Contains("9"));
    }
}

आउटपुट

ListDictionary तत्व...
1 SUV
2 Sedan
3 Utility Vehicle
4 Compact Car
5 SUV
6 Sedan
7 Utility Vehicle
8 Compact Car
9 Crossover
10 Electric Car
क्या ListDictionary का आकार निश्चित है? = False
क्या ListDictionary रीड-ओनली है? = False
क्या ListDictionary सिंक्रनाइज़्ड है? = False
क्या ListDictionary में कुंजी K है? = False
क्या ListDictionary में कुंजी 9 है? = True

एक और उदाहरण

using System;
using System.Collections;
using System.Collections.Specialized;

public class Demo {
    public static void Main() {
        ListDictionary dict1 = new ListDictionary();
        dict1.Add("A", "Books");
        dict1.Add("B", "Electronics");
        dict1.Add("C", "Smart Wearables");
        dict1.Add("D", "Pet Supplies");
        dict1.Add("E", "Clothing");
        dict1.Add("F", "Footwear");

        Console.WriteLine("ListDictionary1 तत्व...");
        foreach(DictionaryEntry d in dict1) {
            Console.WriteLine(d.Key + " " + d.Value);
        }

        ListDictionary dict2 = new ListDictionary();
        dict2.Add("1", "One");
        dict2.Add("2", "Two");
        dict2.Add("3", "Three");
        dict2.Add("4", "Four");
        dict2.Add("5", "Five");
        dict2.Add("6", "Six");

        Console.WriteLine("\nListDictionary2 की-वैल्यू जोड़े...");
        IDictionaryEnumerator demoEnum = dict2.GetEnumerator();
        while (demoEnum.MoveNext())
            Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value);

        Console.WriteLine("क्या ListDictionary का आकार निश्चित है? = " + dict2.IsFixedSize);
        Console.WriteLine("क्या ListDictionary रीड-ओनली है? = " + dict2.IsReadOnly);
        Console.WriteLine("क्या ListDictionary सिंक्रनाइज़्ड है? = " + dict2.IsSynchronized);
        Console.WriteLine("क्या ListDictionary में कुंजी 5 है? = " + dict2.Contains("5"));
    }
}

आउटपुट

ListDictionary1 तत्व...
A Books
B Electronics
C Smart Wearables
D Pet Supplies
E Clothing
F Footwear
ListDictionary2 की-वैल्यू जोड़े...
Key = 1, Value = One
Key = 2, Value = Two
Key = 3, Value = Three
Key = 4, Value = Four
Key = 5, Value = Five
Key = 6, Value = Six
क्या ListDictionary का आकार निश्चित है? = False
क्या ListDictionary रीड-ओनली है? = False
क्या ListDictionary सिंक्रनाइज़्ड है? = False
क्या ListDictionary में कुंजी 5 है? = True
  1. HTML Spell Check (स्पेल चेक) HTML Spell Check (स्पेल चेक)

    विवरण HTML Spell Check का उपयोग HTML टेक्स्ट फील्ड में व्याकरण या वर्तनी की गलतियों की पहचान करने के लिए किया जाता है। सिंटैक्स <tagname spellcheck=true | false> उदाहरण आइए HTML Spell Check का एक उदाहरण देखें: <!DOCTYPE html> <html> <style> body { color: #000;

  1. - C# में Check करें अगर File Hidden है

    File के Attributes Retrieve करने के लिए, FileAttributes Enumeration का उपयोग करें। इसमें Compressed, Directory, Hidden आदि जैसे विभिन्न Members होते हैं। Check करने के लिए कि File Hidden है या नहीं, Hidden Member Name का उपयोग करें। यदि FileAttributes.Hidden Set है तो इसका मतलब File Hidden है। सबसे

  1. - C# प्रोग्राम: जांचें कि मान सरणी में है या नहीं

    किसी मान की जांच के लिए कि वह सरणी में है या नहीं, Array.Exists विधि का उपयोग करें। एक स्ट्रिंग सरणी सेट करें: string[] strArray = new string[] {keyboard, screen, mouse, charger }; मान लीजिए आपको सरणी में keyboard मान खोजना है। इसके लिए Array.Exists() का उपयोग करें: ele == keyboard); यदि तत्व मौजूद