Skip to main content

Delegate C#

1. Delegate là vùng dữ liệu gồm các phương thức ( biến chữa phương thức)
+ Các phương thức có chung kiểu dữ liệu trả về và giống danh sách tham số
2. Đặc điểm
+ Chứa phương thức

[​IMG]

+ Thay đổi được

[​IMG]

+ Có thể chữa nhiều

3. Là 1 thành phần của class
Ủy quyền

PHP:
[/FONT]
 public class 
LTVdotNet
    
{   
        public static 
void LTWebASP(string ten)
        {
            
Console.WriteLine("Da thuc hien web ASP.NET "+ten);
        }
    }

[
SIZE=14px]public  class LTVJava
    
{
      public static 
void LTWebJSP(string ten)
        {
            
Console.WriteLine("Da thuc hien web JSP " ten);
        }
    }[/
SIZE]delegate void dLTWeb(string web);
    class 
LTV
    
{
        public 
dLTWeb LTW;
        public 
void LTWinDowsForm()
        {
            
Console.WriteLine("Lap trinh windows form");
        }
    }
[
FONT=Georgia]

[​IMG]

Khi nào cần dùng delegate:
+ Không cần định nghĩa
+ Cần thay đổi phương thức khi gọi
Bài viết viết bởi StudyCoding

Comments

Popular posts from this blog

Socket Android Client to PC Server C#

Using AsynCallback C# Android Client connect Server C# Source code:  http://ow.ly/OlXj309O1mj c# socket multi client, socket c# example, socket server c#, socket c# tutorial, asynchronous socket in c#, c# socket multiple clients, c# socket server multiple clients, Download source code:  Click Here

Bài tập thuật toán C/C++ Và Tuyển tập đề thi olympic

Gồm: +  Các thuật toán của Lê Minh Hoàng + Tuyển tập các đề thi olympic tin học sinh viên Link down: Tại đây

Cross Platform Mobile App: Demo shop with flutter

Cross Platform Mobile App: Demo shop with flutter So cool framework from google <3  Demo:  Demo Code console.print("hello")