Created
August 23, 2016 07:56
-
-
Save zhenlinyang/c492645a8a1abd4f84fa040f6a661ea1 to your computer and use it in GitHub Desktop.
Linq Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool TryGetPlayerInfoByUserName(string userName, out PlayerInfo playerInfo) | |
{ | |
IEnumerable<PlayerInfo> infoQuery = | |
from info in _PlayerInfoDic.Values | |
where info.UserName == userName | |
select info; | |
if (0 != infoQuery.Count()) | |
{ | |
playerInfo = infoQuery.First(); | |
return true; | |
} | |
else | |
{ | |
playerInfo = null; | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment