資源簡介
模擬一副撲克牌,根據點數、花色等分組、篩選為例子,詳細講解linq中篩選之后的集合到底是引用類型還是值類型,如何才能正確使用篩選后的集合和其中的元素。
壓縮的是一個項目文件,運行時,需要自己新建解決方案,我用的是VS2017。如果版本低于這個的話,只要把其中的program.cs文件中內容復制到自己新建的解決方案中,也可以運行。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?Poker
{
????class?Program
????{
????????static?void?Main(string[]?args)
????????{
????????????test07();
????????????Console.ReadLine();
????????}
????????///?
????????///?根據點數分組,每個組按照點數大小排序,每個組里面的內容,再根據color排序
????????///?
????????static?void?test01()?{
????????????var?cards?=?Card.GetPack();
????????????Card.Shuffle(cards);
????????????//cards?=?Card.RandomN(cards40);
????????????var?a1?=?from?n?in?cards
?????????????????????group?n?by?n.points?into?d1
?????????????????????orderby?d1.Key?descending?????????????????????
?????????????????????select?new
?????????????????????{
?????????????????????????key?=?d1.Key
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????187??2018-12-28?07:09??Poker\App.config
?????文件??????19456??2019-01-10?04:59??Poker\bin\Debug\Poker.exe
?????文件????????187??2018-12-28?07:09??Poker\bin\Debug\Poker.exe.config
?????文件??????44544??2019-01-10?04:59??Poker\bin\Debug\Poker.pdb
?????文件??????22984??2018-12-28?07:09??Poker\bin\Debug\Poker.vshost.exe
?????文件????????187??2018-12-28?07:09??Poker\bin\Debug\Poker.vshost.exe.config
?????文件????????490??2018-12-28?07:09??Poker\bin\Debug\Poker.vshost.exe.manifest
?????文件???????6517??2018-12-28?07:09??Poker\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????42??2019-01-10?04:59??Poker\obj\Debug\Poker.csproj.CoreCompileInputs.cache
?????文件????????902??2019-01-10?04:59??Poker\obj\Debug\Poker.csproj.FileListAbsolute.txt
?????文件???????1705??2018-12-28?07:09??Poker\obj\Debug\Poker.csprojResolveAssemblyReference.cache
?????文件??????19456??2019-01-10?04:59??Poker\obj\Debug\Poker.exe
?????文件??????44544??2019-01-10?04:59??Poker\obj\Debug\Poker.pdb
?????文件??????????0??2018-12-28?07:09??Poker\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2018-12-28?07:09??Poker\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2018-12-28?07:09??Poker\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件???????2551??2018-12-28?07:09??Poker\Poker.csproj
?????文件??????31058??2018-12-28?07:09??Poker\Program.cs
?????文件???????1350??2018-12-28?07:09??Poker\Properties\AssemblyInfo.cs
?????目錄??????????0??2018-12-28?07:10??Poker\obj\Debug\TempPE
?????目錄??????????0??2019-01-10?04:59??Poker\bin\Debug
?????目錄??????????0??2019-01-10?04:59??Poker\obj\Debug
?????目錄??????????0??2018-12-28?07:10??Poker\bin
?????目錄??????????0??2018-12-28?07:10??Poker\obj
?????目錄??????????0??2018-12-28?07:10??Poker\Properties
?????目錄??????????0??2018-12-28?07:10??Poker
-----------?---------??----------?-----??----
???????????????196160????????????????????26
- 上一篇:基于c#的串口通信
- 下一篇:源碼:webapi實現圖形驗證碼
評論
共有 條評論