我目前正在Discord Server中构建一个新命令,并且正在努力将UserId转换回服务器中的Users Nickname。
我收到错误消息运算符’==’在ulong和long类型的操作数上不明确
有人可以帮我弄清楚我做错了什么
Int64 memberId = reader.GetInt64(0); string name = Context.Guild.Users .Where(x => x.Id == memberId) .First() .Nickname != null ? Context.Guild.Users.Where(x => x.Id = memberId).First().Nickname : Context.Guild.Users.Where(x => x.Id = memberId).First().Username; Int64 votes = reader.GetInt64(2); GOTWVote.Add($@"{name} has received {votes} vote(s)");
第一步是强制转换以解决歧义运算符。接下来,重新安排您的查询以摆脱两个额外的子查询:
Int64 memberId = reader.GetInt64(0); var user = Context.Guild.Users .Where(x => x.Id == (UInt64)memberId) .First(); string name = user.Nickname != null ? user.Nickname : user.Username; Int64 votes = reader.GetInt64(2); GOTWVote.Add($@"{name} has received {votes} vote(s)");