Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

คุณสมบัติ Count ของคลาส Stack ใน C#

เพื่อหาจำนวนสมาชิกที่เพิ่มในคลาส Stack ให้ใช้คุณสมบัติ Count

ตัวอย่าง

using System;
using System.Collections;

namespace Demo {
    class Program {
        static void Main(string[] args) {
            Stack st = new Stack();
            st.Push('H');
            st.Push('I');
            st.Push('J');
            st.Push('K');
            st.Push('L');
            st.Push('M');
            st.Push('N');
            st.Push('O');
            Console.WriteLine("Count: " + st.Count);
        }
    }
}

ผลลัพธ์

Count: 8