全球唯一標識符 System.Guid.NewGuid().ToString()


System.Guid.NewGuid().ToString(); //ToString() 為 null 或空字符串 (""),則使用"D"。
結果:820941e4-3dd5-4835-b67a-b19b208428cc

System.Guid.NewGuid().ToString("N"); //32 位:00000000000000000000000000000000
結果:309d5008977f4daeb6a1fda3b1942b71

System.Guid.NewGuid().ToString("D"); //由連字符分隔的 32 位數字:00000000-0000-0000-0000-000000000000
結果:5e1377fe-a5e1-4346-8146-3748108b0efd

System.Guid.NewGuid().ToString("B"); //括在大括號中、由連字符分隔的 32 位數字:{00000000-0000-0000-0000-000000000000}
結果:{ca1fd426-f52f-41b6-8a54-01240edd8939}

System.Guid.NewGuid().ToString("P"); //括在圓括號中、由連字符分隔的 32 位數字:(00000000-0000-0000-0000-000000000000)
結果:(b443153c-4171-4a40-8851-4cd989b314d5)

System.Guid.NewGuid().ToString("X"); //括在大括號的 4 個十六進制值,其中第 4 個值是 8 個十六進制值的子集(也括在大括號中):{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
結果:{0xee3ae5ac,0xd99f,0x421f,{0x87,0xec,0xab,0x02,0xbc,0xaa,0x1e,0x87}}

記錄一下 除了D和N其他經常忘記是什么方式


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM