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

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

उदाहरण 1: दो HybridDictionary के सिंक्रनाइज़ेशन गुण जांचना

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

public class Demo {
    public static void Main() {
        HybridDictionary dict1 = new HybridDictionary();
        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("HybridDictionary1 तत्व...");
        foreach(DictionaryEntry d in dict1) {
            Console.WriteLine(d.Key + " " + d.Value);
        }
        Console.WriteLine("क्या HybridDictionary1 का आकार निश्चित है? = " + dict1.IsFixedSize);
        Console.WriteLine("क्या HybridDictionary1 केवल पढ़ने योग्य है? = " + dict1.IsReadOnly);
        Console.WriteLine("क्या HybridDictionary1 सिंक्रनाइज़्ड है? = " + dict1.IsSynchronized);

        HybridDictionary dict2 = new HybridDictionary();
        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("\nHybridDictionary2 तत्व...");
        foreach(DictionaryEntry d in dict2) {
            Console.WriteLine(d.Key + " " + d.Value);
        }
        Console.WriteLine("क्या HybridDictionary1, HybridDictionary2 के बराबर है? = " + (dict1.Equals(dict2)));
        Console.WriteLine("क्या HybridDictionary2 का आकार निश्चित है? = " + dict2.IsFixedSize);
        Console.WriteLine("क्या HybridDictionary2 केवल पढ़ने योग्य है? = " + dict2.IsReadOnly);
        Console.WriteLine("क्या HybridDictionary2 सिंक्रनाइज़्ड है? = " + dict2.IsSynchronized);
    }
}

आउटपुट

HybridDictionary1 तत्व...
A Books
B Electronics
C Smart Wearables
D Pet Supplies
E Clothing
F Footwear
क्या HybridDictionary1 का आकार निश्चित है? = False
क्या HybridDictionary1 केवल पढ़ने योग्य है? = False
क्या HybridDictionary1 सिंक्रनाइज़्ड है? = False
HybridDictionary2 तत्व...
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
क्या HybridDictionary1, HybridDictionary2 के बराबर है? = False
क्या HybridDictionary2 का आकार निश्चित है? = False
क्या HybridDictionary2 केवल पढ़ने योग्य है? = False
क्या HybridDictionary2 सिंक्रनाइज़्ड है? = False

उदाहरण 2: एक HybridDictionary के गुण जांचना

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

public class Demo {
    public static void Main() {
        HybridDictionary dict = new HybridDictionary();
        dict.Add("1", "Finance");
        dict.Add("2", "Marketing");
        dict.Add("3", "IT");
        dict.Add("4", "Operations");
        dict.Add("5", "Purchase");

        Console.WriteLine("HybridDictionary तत्व...");
        foreach(DictionaryEntry d in dict) {
            Console.WriteLine(d.Key + " " + d.Value);
        }
        Console.WriteLine("क्या HybridDictionary का आकार निश्चित है? = " + dict.IsFixedSize);
        Console.WriteLine("क्या HybridDictionary केवल पढ़ने योग्य है? = " + dict.IsReadOnly);
        Console.WriteLine("क्या HybridDictionary सिंक्रनाइज़्ड है? = " + dict.IsSynchronized);
    }
}

आउटपुट

HybridDictionary तत्व...
1 Finance
2 Marketing
3 IT
4 Operations
5 Purchase
क्या HybridDictionary का आकार निश्चित है? = False
क्या HybridDictionary केवल पढ़ने योग्य है? = False
क्या HybridDictionary सिंक्रनाइज़्ड है? = False
  1. - C# में SortedSet में किसी विशिष्ट तत्व की जांच कैसे करें

    C# में SortedSet किसी विशिष्ट तत्व को रखता है या नहीं, यह जांचने के लिए Contains() मेथड का उपयोग किया जाता है। यह मेथड एक बूलियन मान लौटाता है। उदाहरण 1 using System; using System.Collections.Generic; public class Demo { public static void Main() { SortedSet set1 = new SortedSet();

  1. - C# में Collection में किसी तत्व की जांच कैसे करें

    C# में Collection<T> किसी विशिष्ट तत्व को रखता है या नहीं, यह जांचने के लिए Contains() मेथड का उपयोग किया जाता है। यह मेथड एक बूलियन मान लौटाता है। उदाहरण 1 using System; using System.Collections.ObjectModel; public class Demo { public static void Main() { Collection col = new Col

  1. - C# लिस्ट खाली है या नहीं कैसे चेक करें

    लिस्ट खाली है या नहीं यह जानने के लिए Any मेथड का उपयोग करें। लिस्ट सेट करें - var subjects = new List(); subjects.Add(Maths); subjects.Add(Java); subjects.Add(English); subjects.Add(Science); subjects.Add(Physics); subjects.Add(Chemistry); अब लिस्ट खाली है या नहीं चेक करने के लिए निम्नलिखित कंडीशन