请教List.add 与 Find 语法问题!
reflector 查看源码时发现两个小问题
public static List<MusicEntity> muList = new List<MusicEntity>();
public static void AddMusic(MusicEntity me)
{
Predicate<MusicEntity> match = null;
lock (muList)
{
if (match == null)
{
match = tmp => tmp.Ids == me.Ids;
}
int num = muList.FindIndex(match);
if (num != -1)
{
muList[num] = me;
}
else
{
muList.Insert(0, me);
}
}
}
添加音乐的方法 AddMusic
此行报错
match = tmp => tmp.Ids == me.Ids;
错误 1 应输入 ;
另外一处
new 时也报错
MusicEntity entity = new MusicEntity{
id = 1,
Flag = 0 };
此处报错
错误 2 new 表达式要求在类型后有 () 或 []
请教语法应怎样修正? 我.net很不好,麻烦各位帮忙修正下语句!