Last active
August 11, 2022 09:02
-
-
Save Edkorenkov/6de931b2105fe7ab3546a1f93622a6e9 to your computer and use it in GitHub Desktop.
Random robot name generator in format of XX123 where XX : letters from A to Z
This file contains 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
var name = Guid.NewGuid() | |
.ToString() | |
.Aggregate("", (acc, x) => | |
{ | |
return acc.Length switch | |
{ | |
< 2 when char.IsLetter(x) => $"{acc}{x.ToString().ToUpper()}", | |
>= 2 and < 5 when char.IsDigit(x) => $"{acc}{x.ToString()}", | |
_ => acc | |
}; | |
}); |
This file contains 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
var name = Guid.NewGuid() | |
.ToString() | |
.Where(char.IsLetter) | |
.Take(2) | |
.Select(x => x.ToString()) | |
.Concat(Enumerable.Range(0, 3).Select(_ => $"{RandomNumberGenerator.GetInt32(0, 9)}")) | |
.Aggregate("", (z, x) => $"{z}{x}") | |
.ToUpper(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment