[英]Argument `#2' cannot convert `System.Collections.Generic.List<string>
I'm implementing an achievement system to my game and i can not find the way to solve this error:我正在为我的游戏实施成就系统,但找不到解决此错误的方法:
error CS1503: Argument `#2' cannot convert `System.Collections.Generic.List<string>' expression to type `System.Collections.Generic.List<Achievement>'
This is my code这是我的代码
public AchievementsManager( )
{
_achievementKeeper = new Dictionary<AchievementType, int>();
// ideally, load here previous, saved values.
// tap = 0
// die = 1
// start = 12
// score = 1231
_achievements = new Dictionary<AchievementType, List<Achievement>>();
List<string> listStart = new List<string>();
listStart.Add(new Achievement() { countToUnlock = 3, isUnlocked = false, Message = "First Time Playing!" });
listStart.Add(new Achievement() { countToUnlock = 8, isUnlocked = false, Message = "Fifth Time is the Charm?" });
listStart.Add(new Achievement() { countToUnlock = 10, isUnlocked = false, Message = "Hello and Welcome Back!" });
listStart.Add(new Achievement() { countToUnlock = 16, isUnlocked = false, Message = "Tapping Time!!" });
listStart.Add(new Achievement() { countToUnlock = 50, isUnlocked = false, Message = "Perseverance Lvl 1!" });
_achievements.Add(AchievementType.Start, listStart );
}
You are creating List<string> listStart
, but you are dealing with it as with a List<Achievement>
.您正在创建
List<string> listStart
,但您正在像处理List<Achievement>
一样处理它。 Replace this line替换这一行
List<string> listStart = new List<string>();
with this one:有了这个:
List<Achievement> listStart = new List<Achievement>();
listStart
is of type List<string>
but you are adding to it Achievement
objects. listStart
是List<string>
类型,但您正在向其中添加Achievement
对象。 Change it to将其更改为
List<Achievement> listStart = new List<Achievement>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.