Hashtable क्लास के एलिमेंट्स की संख्या जानने के लिए Count गुण का उपयोग करें। सबसे पहले Hashtable क्लास को एलिमेंट्स के साथ सेट करें:
Hashtable ht = new Hashtable(); ht.Add("One", "Tom"); ht.Add("Two", "Jack"); ht.Add("Three", "Peter"); ht.Add("Four", "Russel"); ht.Add("Five", "Brad"); ht.Add("Six", "Bradley"); ht.Add("Seven", "Steve"); ht.Add("Eight", "David");अब Count गुण का उपयोग करके एलिमेंट्स की संख्या गिनें:
ht.Count
निम्न पूर्ण उदाहरण C# में Hashtable Count गुण के उपयोग के बारे में जानने के लिए है:
उदाहरण
using System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add("One", "Tom"); ht.Add("Two", "Jack"); ht.Add("Three", "Peter"); ht.Add("Four", "Russel"); ht.Add("Five", "Brad"); ht.Add("Six", "Bradley"); ht.Add("Seven", "Steve"); ht.Add("Eight", "David"); Console.WriteLine("Count = " + ht.Count); Console.ReadKey(); } } }आउटपुट
Count = 8