using System;
using System.IO;
namespace DirExe
{
class Program
{
static void Main(string[] args)
{
foreach (var f in Directory.GetFiles(@"c:\users\user\desktop"))
{
Console.WriteLine(f);
};
foreach (var f in Directory.GetFiles(@"c:\windows"))
{
Console.WriteLine(f);
};
}
}
}
c:\users\user\desktop\Aida64.lnk
c:\users\user\desktop\Autoruns64.lnk
c:\users\user\desktop\desktop.ini
c:\users\user\desktop\DiskInfo64.lnk
c:\users\user\desktop\DiskMark64.lnk
c:\users\user\desktop\Far32.lnk
c:\users\user\desktop\ff.#.lnk
c:\users\user\desktop\ff.$nake.lnk
c:\users\user\desktop\ff.0.lnk
c:\users\user\desktop\ff.1.lnk
c:\users\user\desktop\ff.2.lnk
c:\users\user\desktop\ff.3.lnk
c:\users\user\desktop\ff.4.lnk
c:\users\user\desktop\ff.5.lnk
c:\users\user\desktop\ff.6.lnk
c:\users\user\desktop\ff.7.lnk
c:\users\user\desktop\ff.azure.lnk
c:\users\user\desktop\ff.body.lnk
c:\users\user\desktop\ff.game.lnk
c:\users\user\desktop\ff.lex.lnk
c:\users\user\desktop\ff.m$.net.lnk
c:\users\user\desktop\ff.net-war.lnk
c:\users\user\desktop\ff.neuro.lnk
c:\users\user\desktop\ff.rss-0.lnk
c:\users\user\desktop\ff.rss-1.lnk
c:\users\user\desktop\ff.rss-2.lnk
c:\users\user\desktop\ff.rss-3.lnk
c:\users\user\desktop\ff.rss-4.lnk
c:\users\user\desktop\ff.rss-5.lnk
c:\users\user\desktop\ff.rss-6.lnk
c:\users\user\desktop\ff.rss.lnk
c:\users\user\desktop\ff.skt.lnk
c:\users\user\desktop\ff.sql.lnk
c:\users\user\desktop\ff.w.lnk
c:\users\user\desktop\ff.x.lnk
c:\users\user\desktop\ff.z.g.p.lnk
c:\users\user\desktop\ff.z.s.s.lnk
c:\users\user\desktop\ff.?.lnk
c:\users\user\desktop\ff.?.lnk
c:\users\user\desktop\HDDScan.lnk
c:\users\user\desktop\HxD64.lnk
c:\users\user\desktop\KeePassXC.lnk
c:\users\user\desktop\rufus.lnk
c:\users\user\desktop\Scanner.lnk
c:\users\user\desktop\ShareX.lnk
c:\users\user\desktop\test.pdf
c:\users\user\desktop\TV.lnk
c:\users\user\desktop\uCalendar.lnk
c:\users\user\desktop\UWT4.lnk
c:\users\user\desktop\WatchMe.lnk
c:\users\user\desktop\Wire.lnk
c:\users\user\desktop\WSU18x64.lnk
c:\windows\bfsvc.exe
c:\windows\bootstat.dat
c:\windows\DtcInstall.log
c:\windows\EnterpriseS.xml
c:\windows\explorer.exe
c:\windows\HelpPane.exe
c:\windows\hh.exe
c:\windows\KB909394.log
c:\windows\lsasetup.log
c:\windows\mib.bin
c:\windows\notepad.exe
c:\windows\PFRO.log
c:\windows\regedit.exe
c:\windows\setupact.log
c:\windows\setuperr.log
c:\windows\splwow64.exe
c:\windows\system.ini
c:\windows\twain_32.dll
c:\windows\win.ini
c:\windows\WindowsShell.Manifest
c:\windows\WindowsUpdate.log
c:\windows\winhlp32.exe
c:\windows\WMSysPr9.prx
c:\windows\write.exe
namespace DelegateDemo
{
public delegate string DemoDel(string s);
class Program
{
static void Main(string[] args)
{
ParamMethod(DelLink); // передача ссылки на метод DelLink в ParamMethod
ParamMethod(s => "(" + s + ")"); // передача анонимной функции в ParamMethod
Console.ReadKey();
}
static bool ParamMethod(DemoDel d)
{
if(d("что угодно") == "2")
{
Console.WriteLine("делегат вернул 2");
}
if(d("5") == "(5)" && d("100500") == "(100500)")
{
Console.WriteLine("делегат обернул число в скобки");
}
}
static string DelLink(string s)
{
return "2";
}
}
}
В чем моя ошибка?