diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs index 71a9025..e1bc43b 100644 --- a/X10D/src/StringExtensions.cs +++ b/X10D/src/StringExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; + using System.Linq; using System.Net; using System.Security; using System.Text; @@ -150,6 +151,27 @@ return builder.ToString(); } + /// + /// Shuffles the characters in the string. + /// + /// The string to shuffle. + /// Returns a containing the characters in , rearranged. + public static string Shuffle(this string str) + { + return str.Shuffle(new Random()); + } + + /// + /// Shuffles the characters in the string. + /// + /// The string to shuffle. + /// The instance. + /// Returns a containing the characters in , rearranged. + public static string Shuffle(this string str, Random random) + { + return new string(str.ToCharArray().Shuffle(random).ToArray()); + } + /// /// Splits the into chunks that are no greater than in length. ///