Delegate با پارامترهای reference در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، Delegate با پارامترهای reference در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی پروژه به این صورت می باشد:
Value: 12
Delegate با پارامترهای reference :
using System;
delegate void FunctionToCall(ref int X);
class MainClass
{
public static void Add2(ref int x) {
x += 2;
}
public static void Add3(ref int x) {
x += 3;
}
static void Main(string[] args)
{
FunctionToCall functionDelegate = Add2;
functionDelegate += Add3;
delegate void FunctionToCall(ref int X);
class MainClass
{
public static void Add2(ref int x) {
x += 2;
}
public static void Add3(ref int x) {
x += 3;
}
static void Main(string[] args)
{
FunctionToCall functionDelegate = Add2;
functionDelegate += Add3;