using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public delegate int first(int n);
namespace ConsoleApplication4
{
class Program
{
static int n = 25;
public static int add(int p)
{
n += p;
return n;
}
public static int sub(int p)
{
n -= p;
return n;
}
public static int mul(int p)
{
n *= p;
return n;
}
public static int div(int p)
{
n /= p;
return n;
}
public static int getn()
{ return n;}
static void Main(string[] args)
{
first f;
first f1 = new first(add);
first f2 = new first(sub);
first f3 = new first(mul);
first f4 = new first(div);
f = f1;
f += f2;
f += f3;
f += f4;
f(5);
Console.WriteLine("value is:" + getn());
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
public delegate int first(int n);
namespace ConsoleApplication4
{
class Program
{
static int n = 25;
public static int add(int p)
{
n += p;
return n;
}
public static int sub(int p)
{
n -= p;
return n;
}
public static int mul(int p)
{
n *= p;
return n;
}
public static int div(int p)
{
n /= p;
return n;
}
public static int getn()
{ return n;}
static void Main(string[] args)
{
first f;
first f1 = new first(add);
first f2 = new first(sub);
first f3 = new first(mul);
first f4 = new first(div);
f = f1;
f += f2;
f += f3;
f += f4;
f(5);
Console.WriteLine("value is:" + getn());
Console.ReadKey();
}
}
}
No comments:
Post a Comment