c#委托调用另一窗口函数_在C#中使用委托调用成员函数

本文介绍了如何在C#中通过委托调用类的成员函数,将其与静态函数调用相比较,并提供了一个示例程序,展示如何创建委托引用并使用类对象传递成员函数。
摘要由CSDN通过智能技术生成

c#委托调用另一窗口函数

Prerequisite: Delegates in C#

先决条件: C#中的代表

We can also call a member function of a class using delegates. It is similar to static function calls, here we have to pass member function using an object on the creation of delegate.

我们还可以使用委托来调用类的成员函数。 它类似于静态函数调用,这里我们必须在创建委托时使用对象传递成员函数。

Program:

程序:

using System;
using System.Collections;

public delegate void myDelegates();
class Sample
{
   
    public void fun()
    {
   
        Console.WriteLine("Call a member function using delegate");
    }
}


class Program
{
   
   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值