استفاده از Anonymous delegate method برای ساخت برنامه اعداد مربع کامل در #C
سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب ، استفاده از Anonymous delegate method برای ساخت برنامه اعداد مربع کامل در سی شارپ #C رو براتون آماده کردم. انشاالله که این کد براتون مفید باشه.
خروجی پروژه به این صورت می باشد:
0
1
4
9
16
25
36
49
64
81
100
1
4
9
16
25
36
49
64
81
100
استفاده از Anonymous delegate method برای ساخت برنامه اعداد مربع کامل :
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
delegate int IntDelegate(int x);
public class MainClass
{
static void TransformUpTo(IntDelegate d, int max)
{
for (int i = 0; i <= max; i++)
Console.WriteLine(d(i));
}
public static void Main(){
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
delegate int IntDelegate(int x);
public class MainClass
{
static void TransformUpTo(IntDelegate d, int max)
{
for (int i = 0; i <= max; i++)
Console.WriteLine(d(i));
}
public static void Main(){