我无法从 ForEach 返回,这是我的代码:
cards.ForEach(delegate(Card c){
if (c.GetFaceValue().ToString() == card) {
return "Your Card has been located";
}
错误:
无法将匿名方法转换为委托类型“... .Card>”,因为块中的某些返回类型不能隐式转换为委托返回类型
以下也不起作用,因为CheckCard
只能返回 void:
cards.ForEach(CheckCard);
public string CheckCard(Card c) {
if (c.GetFaceValue().ToString() == card) { // card = global
return "Your Card has been located";
}
}
错误:
'string SharedGamesClasses.Hand.CheckCard(SharedGamesClasses.Card)' 的返回类型错误