0

我有以下列表类

public class Users
{
    public string Username
    {
        get;
        set;
    }

    public string PlayerID
    {
        get;
        set;
    }
}

我想知道如何选择 username = x 的 playerID ?

4

1 回答 1

1
var player = playerList.FirstOrDefault(p => p.Username == "x");
if(player != null)
{
    string id = player.PlayerID;
}
于 2013-02-24T19:49:28.913 回答