One name many forms



Download 128,5 Kb.
bet5/7
Sana01.01.2022
Hajmi128,5 Kb.
#294628
1   2   3   4   5   6   7
Bog'liq
Polymorphism in C#

public abstract class AppleBase  

  •    {  

  •        public AppleBase()  

  •        {  

  •   

  •        }  

  •        public abstract void SetPrice();  

  •    } 



    First, if I try to create an object of an abstract class what will happen?

     

     

    There, it's a compile-time error. forget about running your program, not even complier is ready to allow that.



     

    So basically we can not create an instance to call a constructor. But it is not the only way to call a constructor.

     

    Ever heard about Constructor chaining



    •  Constructor Chaining is a concept when a constructor calls another constructor in the same class or its base class.

    Let me explain it to you with an example.

     

    Say we have base class AppleBase which is printing a message in its constructor.




    1. Download 128,5 Kb.

      Do'stlaringiz bilan baham:
  • 1   2   3   4   5   6   7




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

    kiriting | ro'yxatdan o'tish
        Bosh sahifa
    юртда тантана
    Боғда битган
    Бугун юртда
    Эшитганлар жилманглар
    Эшитмадим деманглар
    битган бодомлар
    Yangiariq tumani
    qitish marakazi
    Raqamli texnologiyalar
    ilishida muhokamadan
    tasdiqqa tavsiya
    tavsiya etilgan
    iqtisodiyot kafedrasi
    steiermarkischen landesregierung
    asarlaringizni yuboring
    o'zingizning asarlaringizni
    Iltimos faqat
    faqat o'zingizning
    steierm rkischen
    landesregierung fachabteilung
    rkischen landesregierung
    hamshira loyihasi
    loyihasi mavsum
    faolyatining oqibatlari
    asosiy adabiyotlar
    fakulteti ahborot
    ahborot havfsizligi
    havfsizligi kafedrasi
    fanidan bo’yicha
    fakulteti iqtisodiyot
    boshqaruv fakulteti
    chiqarishda boshqaruv
    ishlab chiqarishda
    iqtisodiyot fakultet
    multiservis tarmoqlari
    fanidan asosiy
    Uzbek fanidan
    mavzulari potok
    asosidagi multiservis
    'aliyyil a'ziym
    billahil 'aliyyil
    illaa billahil
    quvvata illaa
    falah' deganida
    Kompyuter savodxonligi
    bo’yicha mustaqil
    'alal falah'
    Hayya 'alal
    'alas soloh
    Hayya 'alas
    mavsum boyicha


    yuklab olish