सबसे पहले, एक स्ट्रिंग सरणी सेट करें।
string[] num = { "One", "Two", "Three", "Four", "Five"};तत्वों की संख्या प्राप्त करने के लिए LINQ LongCount मेथड का उपयोग करें।
num.AsQueryable().LongCount();
यहाँ पूरा कोड है:
उदाहरण
using System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { string[] num = { "One", "Two", "Three", "Four", "Five"}; long res = num.AsQueryable().LongCount(); Console.WriteLine("{0} तत्व", res); } }आउटपुट
5 तत्व