কম্পিউটার টিউটোরিয়াল

C#-এ SortedDictionary.Add() পদ্ধতি


C#-এ SortedDictionary.Add() পদ্ধতিটি ব্যবহার করা হয় SortedDictionary<TKey, TValue>-এ নির্দিষ্ট কী (key) এবং মান (value) সহ একটি উপাদান যোগ করতে।

সিনট্যাক্স

সিনট্যাক্স নিম্নরূপ -

public void Add (TKey key, TValue val);

উপরে, মান key হলো যোগ করার উপাদানের কী, আর val হলো যোগ করার উপাদানের মান।

উদাহরণ

এখন একটি উদাহরণ দেখি -

using System; 
using System.Collections; 
using System.Collections.Generic; 
public class Demo { 
    public static void Main(){ 
        SortedDictionary sortedDict = new SortedDictionary(); 
        sortedDict.Add(100, "Mobile"); 
        sortedDict.Add(200, "Laptop"); 
        sortedDict.Add(300, "Desktop"); 
        sortedDict.Add(400, "Speakers"); 
        sortedDict.Add(500, "Headphone"); 
        sortedDict.Add(600, "Earphone"); 
        Console.WriteLine("SortedDictionary key-value pairs..."); 
        IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator(); 
        while (demoEnum.MoveNext()) 
            Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value); 
    } 
}

আউটপুট

এটি নিম্নলিখিত আউটপুট তৈরি করবে -

SortedDictionary key-value pairs...
Key = 100, Value = Mobile
Key = 200, Value = Laptop
Key = 300, Value = Desktop
Key = 400, Value = Speakers
Key = 500, Value = Headphone
Key = 600, Value = Earphone

উদাহরণ

এখন আরেকটি উদাহরণ দেখি -

using System; 
using System.Collections; 
using System.Collections.Generic; 
public class Demo { 
    public static void Main(){ 
        SortedDictionary sortedDict = new SortedDictionary(); 
        sortedDict.Add("A", "John"); 
        sortedDict.Add("B", "Andy"); 
        sortedDict.Add("C", "Tim"); 
        sortedDict.Add("D", "Ryan"); 
        sortedDict.Add("E", "Kevin"); 
        sortedDict.Add("F", "Katie"); 
        sortedDict.Add("G", "Brad"); 
        Console.WriteLine("SortedDictionary key-value pairs..."); 
        IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator(); 
        while (demoEnum.MoveNext()) 
            Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value); 
        Console.WriteLine("\nThe SortedDictionary has the key F? = "+sortedDict.ContainsKey("F")); 
    } 
}

আউটপুট

এটি নিম্নলিখিত আউটপুট তৈরি করবে -

SortedDictionary key-value pairs...
Key = A, Value = John
Key = B, Value = Andy
Key = C, Value = Tim
Key = D, Value = Ryan
Key = E, Value = Kevin
Key = F, Value = Katie
Key = G, Value = Brad
The SortedDictionary has the key F? = True

  1. Node.js-এ crypto.pbkdf2() মেথড

  2. Node.js-এ crypto.generateKeyPairSync() মেথড

  3. Node.js-এ crypto.generateKeyPair() মেথড

  4. HTML DOM insertBefore() মেথড