Sinfning konstanta maydonlari. Qism sinflar bilan ishlash. Sinflar


Download 19 Kb.
bet3/3
Sana31.08.2023
Hajmi19 Kb.
#1671800
1   2   3
Bog'liq
Mavzu Sinfning konstanta maydonlari. Qism sinflar bilan ishlash

Sinfning statistik elementlari.
Siz sinf elementini yo statistik (statistic member), yo nusxa(instance
member) qilib aniqlashingiz mumkin. Bu shuni anglatadiki, har bir sinf nusxasi
uchun har bir element nusxalanadi. Agar siz elementni statistic deb e‘lon
qilsangiz undan faqat birta nusxa olinadi. Statistic element dastur joriy sinfni
ishga tushirganidan boshlab to dastur yakunlanganicha “yashaydi”. Masalan:
using System;
class InstCount{
public InstCount IS
}
instanceCount++;
static public int instanceCount; //instanceCount = 0;
class AppClass {
public static void Main() {
Console.WriteLine(InstCount.instanceCount)
InstCount ic1 = new InstCount ();
Console.WriteLine(InstCount.instanceCount);
InstCount ic2 = new InstCount ();
Console.WriteLine(InstCount.instanceCount) ; }
Download 19 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling