C# — Shuffle a String in One Line
Need to randomly shuffle the characters of a string? Most people would loop and swap, but here’s a LINQ one-liner:
✅ What’s cool about it?
-
Uses
OrderBy
withGuid.NewGuid()
for randomness. -
No loops or manual swaps needed.
-
Works with any string—names, codes, even emojis.
π§© Curiosity twist: Shuffle words instead of characters!
Example output:
✍️ Written by Luis Fernandez Leyva, Software Engineer
Comments
Post a Comment