From what I understand the following code will create a string looking like "xxxx-xxxxx .. etc"
UserUId = Guid.NewGuid().ToString();
What I would like to do is to capture the first five x's. I know I can do this to get the first 4 but how can I skip the "-" and get the first 5, without first putting the Guid into a variable and then using that variable twice with substrings.
UserUId = Guid.NewGuid().ToString().Substring(0, 4);
You can use the N format specifier to get the guid without any extra formatting:
UserUId = Guid.NewGuid().ToString("N").Substring(0, 5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With