در این مثال درباره تابع در سی شارپ صحبت کردیم تابع در سی شارپ همیشه قبل از تابع اصلی () Main قرار میگیرد تابع چیزی جزو صدا زدن مقدایر و متغیر ها نیست
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fun_2
{
internal class Program
{
static int f(int x )
{
return 2*x ;
}
static void Main(string[] args)
{
int a = 2;
int b;
b = f(a);
Console.WriteLine( b );
}
}
}
- ۰۱/۰۵/۱۴