حذف delegate از حالت Multicast در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، حذف delegate از حالت Multicast در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی پروژه به این صورت می باشد:
DoSomething
حذف delegate از حالت Multicast :
using System;
class MainClass
{
delegate int MyDelegate(string s);
static void Main(string[] args)
{
string MyString = "Hello World";
//Or you can Multicast delegates by doing this
MyDelegate Multicast = null;
Multicast += new MyDelegate(DoSomething);
Multicast += new MyDelegate(DoSomething2);
Multicast -= new MyDelegate(DoSomething2);
Multicast(MyString);
}
static int DoSomething(string s)
{
Console.WriteLine("DoSomething");
class MainClass
{
delegate int MyDelegate(string s);
static void Main(string[] args)
{
string MyString = "Hello World";
//Or you can Multicast delegates by doing this
MyDelegate Multicast = null;
Multicast += new MyDelegate(DoSomething);
Multicast += new MyDelegate(DoSomething2);
Multicast -= new MyDelegate(DoSomething2);
Multicast(MyString);
}
static int DoSomething(string s)
{
Console.WriteLine("DoSomething");