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

C# में Dictionary.Values प्रॉपर्टी


C# में Dictionary.Values प्रॉपर्टी का उपयोग Dictionary में सभी मानों को प्राप्त करने के लिए किया जाता है।

सिंटैक्स

निम्नलिखित सिंटैक्स है -

public System.Collections.Generic.Dictionary<TKey, TValue>.ValueCollection Values{ get; }

उदाहरण

आइए Dictionary.Values प्रॉपर्टी को लागू करने का एक उदाहरण देखते हैं -

using System; 
using System.Collections.Generic; 
public class Demo { 
    public static void Main(){ 
        Dictionary<string, string> dict = new Dictionary<string, string>(); 
        dict.Add("One", "Kagido"); 
        dict.Add("Two", "Ngidi"); 
        dict.Add("Three", "Devillers"); 
        dict.Add("Four", "Smith"); 
        dict.Add("Five", "Warner"); 
        Console.WriteLine("Count of elements = "+dict.Count); 
        Console.WriteLine("\nKey/value pairs..."); 
        foreach(KeyValuePair<string, string> res in dict){ 
            Console.WriteLine("Key = {0}, Value = {1}", res.Key, res.Value); 
        } 
        Console.Write("\nAll the values..\n"); 
        Dictionary<string, string>.ValueCollection allValues= dict.Values; 
        foreach(string str in allValues){ 
            Console.WriteLine("Value = {0}", str); 
        } 
    } 
}

आउटपुट

यह निम्नलिखित आउटपुट देगा -

Count of elements = 5 Key/value pairs... Key = One, Value = Kagido Key = Two, Value = Ngidi Key = Three, Value = Devillers Key = Four, Value = Smith Key = Five, Value = Warner All the values.. Value = Kagido Value = Ngidi Value = Devillers Value = Smith Value = Warner

दूसरा उदाहरण

आइए Dictionary.Values प्रॉपर्टी को लागू करने का एक और उदाहरण देखते हैं -

using System; 
using System.Collections.Generic; 
public class Demo { 
    public static void Main(){ 
        Dictionary<int, string> dict = new Dictionary<int, string>(); 
        dict.Add(1, "Kagido"); 
        dict.Add(2, "Ngidi"); 
        dict.Add(3, "Devillers"); 
        Console.WriteLine("Count of elements = "+dict.Count); 
        Console.WriteLine("\nKey/value pairs..."); 
        foreach(KeyValuePair<int, string> res in dict){ 
            Console.WriteLine("Key = {0}, Value = {1}", res.Key, res.Value); 
        } 
        Console.Write("\nAll the values..\n"); 
        Dictionary<int, string>.ValueCollection allValues= dict.Values; 
        foreach(string str in allValues){ 
            Console.WriteLine("Value = {0}", str); 
        } 
    } 
}

आउटपुट

यह निम्नलिखित आउटपुट देगा -

Count of elements = 3 Key/value pairs... Key = 1, Value = Kagido Key = 2, Value = Ngidi Key = 3, Value = Devillers All the values.. Value = Kagido Value = Ngidi Value = Devillers
  1. HTML Window pageXOffset प्रॉपर्टी HTML Window pageXOffset प्रॉपर्टी

    विवरण HTML Window pageXOffset प्रॉपर्टी पिक्सेल में मान लौटाती है कि वर्तमान दस्तावेज़ बाएं कोने से क्षैतिज रूप से कितना स्क्रॉल किया गया है। सिंटैक्स window.pageXOffset उदाहरण आइए HTML Window pageXOffset प्रॉपर्टी का एक उदाहरण देखें: <!DOCTYPE html> <html> <style> body {

  1. HTML Window pageYOffset प्रॉपर्टी HTML Window pageYOffset प्रॉपर्टी

    HTML Window pageYOffset प्रॉपर्टी पिक्सेल में वह मान लौटाती है जिससे वर्तमान दस्तावेज़ ऊपरी बाएं कोने से लंबवत रूप से स्क्रॉल किया गया है।सिंटैक्सनिम्नलिखित सिंटैक्स है:window.pageYOffsetआइए HTML Window pageYOffset प्रॉपर्टी का एक उदाहरण देखें:उदाहरण<!DOCTYPE html> <html> <style> &

  1. HTML DOM value प्रॉपर्टी HTML DOM value प्रॉपर्टी

    HTML DOM value प्रॉपर्टी HTML DOM value प्रॉपर्टी एक एलिमेंट के एट्रिब्यूट के मान से संबंधित एक स्ट्रिंग लौटाती है। सिंटैक्स स्ट्रिंग मान प्राप्त करना elementAttribute.value उदाहरण आइए HTML DOM value प्रॉपर्टी का एक उदाहरण देखें: <!DOCTYPE html> <html> <head> <title>HTML