सबसे पहले, एक स्ट्रिंग ऐरे सेट करें।
string[] num = { "One", "Two", "Three", "Four", "Five"}; तत्वों की संख्या प्राप्त करने के लिए लिंक लॉन्गकाउंट विधि का उपयोग करें।
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} elements", res);
}
} आउटपुट
5 elements