C#???????: ?????к????
???????????? ???????[ 2016/6/2 11:20:30 ] ??????????????????? .NET
????1.5 ???????
??????????????е?????????????????????????????衣????????????????????????????γ???????????Action??Func??Predicate????????????????裬?????á?
????C#
public class Program
{
public static void Main(string[] args)
{
//Action
Actionstring> action = delegate(string str) { Console.WriteLine("???!" + str); };
action("GG");
//Func
Funcint?? int?? int> func = delegate(int x?? int y) { return x + y; };
Console.WriteLine("????????" + func(5?? 6));
//Predicate
Predicatebool> per = delegate(bool isTrue) { return isTrue == true; };
Console.WriteLine(per(true));
}
}
????????????????£?
????Action??У?????????????ж?????????????з??????
????Func??У?????????????ж?????????????з??????
????Predicate??У?????????????????????????????????bool?????
????2. ???
????????????????????????????У??????????????????е?????????????????????????????????????????п?????????λ?????????????????????????????????????????????е??á??????????????????????????С?
????2.1 ???????
?????????????????????????????????
????C#
///
/// ?????????
///
public class MusicPlayer
{
//step01?????? ?????????? ???
public event EventHandler PlayOverEvent;
public string Name { get; set; }
public MusicPlayer(string name)
{
this.Name = name;
}
//step02?????????????????????
public void PlaySong()
{
//?????
Console.WriteLine("????????????" + this.Name);
for (int i = 0; i 20; i++)
{
Console.Write(".");
Thread.Sleep(100);
}
//?????????????PlayOverEvent???
if (PlayOverEvent != null)
{
PlayOverEvent(this?? null);
}
}
}
public class Program
{
static void Main(string[] args)
{
//?????????????????
MusicPlayer player = new MusicPlayer("???????");
//step03????????
player.PlayOverEvent += player_PlayOverEvent;
//????????????????????
player.PlaySong();
Console.ReadKey();
}
static void player_PlayOverEvent(object sender??EventArgs e)
{
MusicPlayer player = sender as MusicPlayer;
Console.WriteLine("rn{0}???????"?? player.Name);
}
}
???????????н????
??????1??????????????????????裺
????step01????event????????????????????????????????????
????step02????????????崥????????????
????step03?????????????????????????
??????2??public event EventHandler PlayOverEvent
????????????MusicPlayer???????????????PlayOverEvent??????????????????С?????е??????????????EventHandler???????????????????????????????£?
????EventHandler???????????????У????????з???????????????????sender???????????????????????????TEventArgs??????????????????????????????System.EventArgs??
????2.2 ????????
????C#
????MusicPlayer player = new MusicPlayer("???????");
????//??????
????player.PlayOverEvent += player_PlayOverEvent;
????player.PlaySong();
????????????????????????????”+=”????????????????????????????????????Delegate.Combine???????????????????????????????????£?
???????????PlayOverEvent??????????????????????add_ PlayOverEvent??remove_ PlayOverEvent??add???????????Delegate.Combine????????????????????б??remove???????????Delegate.Remove??????б??????????????????????????????????????С?
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????C#?е?StringC# Socket???????????????????C#?????????????????????????C#???????C#????????????Log4net??????δ????C#?????????????C#?????????????????C#???????????????C#????????????????C#7 ?е?Tuple??????C#??TypeScript - GeneratorC# ?????????細??????????C#?е???н???C#??MySQL?????????μ??Ч?????д??C#????C++??dll???C#??VS2010????е??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????