Delegate با مقادیر بازگشتی در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، Delegate با مقادیر بازگشتی در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی پروژه به این صورت می باشد:
Value: 12
Delegate با مقادیر بازگشتی :
using System;
delegate int FunctionToCall();
class MainClass
{
static int IntValue = 5;
public static int Add2() {
IntValue += 2;
return IntValue;
}
public static int Add3() {
IntValue += 3;
return IntValue;
}
static void Main()
{
FunctionToCall functionDelegate = Add2;
delegate int FunctionToCall();
class MainClass
{
static int IntValue = 5;
public static int Add2() {
IntValue += 2;
return IntValue;
}
public static int Add3() {
IntValue += 3;
return IntValue;
}
static void Main()
{
FunctionToCall functionDelegate = Add2;