Interfeys toifalari tushunchasi Interfeys toifalarni abstract bazaviy sinflar bilan taqqoslash Maxsus interfeyslarni kiritish


public delegate string MyDelegate(bool a, bool b, bool c)


Download 0.77 Mb.
bet32/50
Sana26.01.2023
Hajmi0.77 Mb.
#1129439
1   ...   28   29   30   31   32   33   34   35   ...   50
Bog'liq
MAVZULAR UMUMIY

public delegate string MyDelegate(bool a, bool b, bool c) ;
Bu holda kompilyator yaratgan kod:
sealed class MyDelegate : System.MulticastDelegate
{
public string Invoke (bool a, bool b, bool c) ;
public IAsyncResult Beginlnvoke(bool a, bool b, bool c,
AsyncCallback cb, object state);
public string Endlnvoke(IAsyncResult result);
}
Yana boshqa bir misol:
public delegate string MyOtherDelegate (out bool a, ref bool b, int c) ;
Bu holda kompilyator yaratgan kod:
public sealed class MyOtherDelegate : System.MulticastDelegate
{
public string Invoke (out bool a, ref bool b, int c) ;
public IAsyncResult Beginlnvoke (out bool a, ref bool b, int c,
AsyncCallback cb, object state);
public string Endlnvoke (out bool a, ref bool b, IAsyncResult result) ;
}
Bu oxirgi misolda EndInvoke() metodida paydo bo’lgan out bool a, ref bool b parametrlarga e’tibor bering.
Bundan xulosa qilaylik: C# da delegat toifasini e’lon qilish natijasida parametrlarining toifalari va qaytaradigan toifalari shu e’longa asoslangan uchta metodni o’z ichiga olgan muhrlangan sinf yaratiladi kompilyator tomonidan. Bunda asosiy andoza taxminan ushbu psevdokod orqali ifodalanishi mumkin:
// Bu bor-yog’I psevdokod!
public sealed class DelegatNomi : System.MulticastDelegate
{
public DelegatQaytaruvchiQiymat
Invoke (Delegatning barcha kiruvchi parametrlari) ;
public IAsyncResult Beginlnvoke (Delegatning barcha kiruvchi parametrlari,
AsyncCallback cb, object state);
public DelegatQaytaruvchiQiymat
Endlnvoke(Delegatning barcha ref va out parametrlari,
IAsyncResult result);
}
Shunday qilib, siz delegate kalit so’zidan foydalanib toifa yaratganingizda, bu toifangiz nooshkor tarzda System.MulticastDelegate sinfi vorisi sifatida yaratiladi:

Download 0.77 Mb.

Do'stlaringiz bilan baham:
1   ...   28   29   30   31   32   33   34   35   ...   50




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