c# - Adding a `-` to a string once at 8 chars, then again at 4? -


i've been trying past hour , it's driving me insane. trying minecraft uuid proper formatting (with dashes), api use gives in regular format.

what have: 7a4730f8f948471dbc77f6f71a250f87

proper format: 7a4730f8-f948-471d-bc77-f6f71a250f87

how go formatting string this?

the .net framework has guid class. can invoke constructor , use .tostring() above described format. instance:

csharp> new guid("7a4730f8f948471dbc77f6f71a250f87") 7a4730f8-f948-471d-bc77-f6f71a250f87 csharp> new guid("7a4730f8f948471dbc77f6f71a250f87").tostring() "7a4730f8-f948-471d-bc77-f6f71a250f87" 

in case process uuids internally, advice use guid class instead of string: since can compare 2 guids, etc.

furthermore expect there less bugs in .net framework in code created users (not because less competent, because number of users of .net framework large, bugs spotted , solved).


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -