• Ekran natijalari
  • 1. System. Object sinfi va uning usullari Umumlashtirish




    Download 70,5 Kb.
    bet12/12
    Sana18.05.2024
    Hajmi70,5 Kb.
    #241174
    1   ...   4   5   6   7   8   9   10   11   12
    Bog'liq
    22-09

    MemberwiseClone()

    Ushbu usul operativ xotirada ushbu turdagi ob'ekt egallagan maydonga yana bir havola yaratish uchun mo'ljallangan. Ushbu usulni ortiqcha yuklash mumkin emas. Agar siz RAMda ob'ektning to'liq nusxasini yaratishni qo'llab-quvvatlashni amalga oshirishingiz kerak bo'lsa, ICloneable interfeysini qo'llab-quvvatlashingiz kerak.


    Quyidagi misol sanab o'tilgan usullardan ba'zilarining imkoniyatlarini ko'rsatadi.



    using System;
    namespace Test
    {
    //*******************************************************
    class ObjTest
    {
    }
    //*******************************************************
    class App
    {
    static void Main()
    {
    // Uyumda ob'ekt yarating
    ObjTest obj1 = new ObjTest();
    // Usullar bo'yicha qaytarilgan ma'lumotlarni ko'rsatish
    // System.Object bazaviy sinfi
    Console.WriteLine("ToString(): {0}",
    obj1.ToString());
    Console.WriteLine("GetHashCode(): {0}",
    obj1.GetHashCode());
    Console.WriteLine("GetType(): {0}",
    obj1.GetType().ToString());
    // Obj1 ga yana ikkita havola yarating
    ObjTest obj2 = obj1;
    object obj3 = obj2;
    // Barcha uchta havolaning haqiqiyligini tekshiring
    // RAMning bir xil maydoniga ishora
    if(obj1.Equals(obj2) && obj2.Equals(obj3))
    Console.WriteLine("Xotira manzillari mos keladi ");
    while(true);
    }
    }
    }
    Listing 11.16. System.Object klassi usullarining imkoniyatlarini namoyish qilish.
    Ekran natijalari
    ToString(): Test.ObjTest
    GetHashCode(): 2
    GetType(): Test.ObjTest
    Xotira manzillari mos keladi
    http://fayllar.org
    Download 70,5 Kb.
    1   ...   4   5   6   7   8   9   10   11   12




    Download 70,5 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    1. System. Object sinfi va uning usullari Umumlashtirish

    Download 70,5 Kb.