我有以下列表类
public class Users
{
public string Username
{
get;
set;
}
public string PlayerID
{
get;
set;
}
}
我想知道如何选择username = x的播放器ID?
答案 0 :(得分:1)
var player = playerList.FirstOrDefault(p => p.Username == "x");
if(player != null)
{
string id = player.PlayerID;
}