Question: How do I repeat generating a random char? I want to make a glitched text effect so I set:

```
textbox.text = st[Random.Range(0, st.Length)];

```

in my update method. I do however only get one character out of this line - how would I repeat this process in a string with the length of 5? What I am trying to achieve is to randomly generate 5 characters over and over again. There must be a better way than this:

```
randomChar + randomChar + randomChar + randomChar + randomChar

```

Thank you in advance!

Answer: 
Could use something similar:

```
 public static readonly char[] CHARS = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
    static void Main(string[] args)
    {

        static string GenerateGlitchedString(uint wordCount,uint wordslength)
        {
            string glitchedString = "";

            for (int i = 0; i < wordCount; i++) 
            {
                for (int j = 0; j < wordslength; j++) 
                {
                    Random rnd = new Random();
                    glitchedString += CHARS[rnd.Next(CHARS.Length)];
                }
                glitchedString += " "; //Add spaces
            }
            return glitchedString;
        }

        string output = GenerateGlitchedString(5, 5);
        Console.WriteLine(output);
    }

```
If you want completely glitchy strings, go the way of [Mojibake](https://en.wikipedia.org/wiki/Mojibake). Take a string, convert it to one encoding and then decode it differently. Most programmers end up familiar with this kind of glitch eventually. For example this code:

```
const string startWith = "Now is the time for all good men to come to the aid of the party";
var asBytes = Encoding.UTF8.GetBytes(startWith);
var glitched = Encoding.Unicode.GetString(asBytes);
Debug.WriteLine(glitched);

```

consistently results in:

```
潎⁷獩琠敨琠浩⁥潦⁲污⁬潧摯洠湥琠⁯潣敭琠⁯桴⁥楡⁤景琠敨瀠牡祴

```

But, if you just want some text with some random glitches, how about something like this. It uses a set of characters that should be glitched in, a count of how many glitches there should be in a string (based on the string length) and then randomly inserts glitches:

```
private static Random _rand = new Random();
private const string GlitchChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%&";
public static string GlitchAString(string s)
{
    var glitchCount = s.Length / 5;
    var buffer = s.ToCharArray();
    for (var i = 0; i < glitchCount; ++i)
    {
        var position = _rand.Next(s.Length);
        buffer[position] = GlitchChars[_rand.Next(GlitchChars.Length)];
    }

    var result = new string(buffer);
    Debug.WriteLine(result);
    return result;
}

```

The first two times I ran this (with that same `Now is the time...` string), I got:

```
Original String:
    Now is the time for all good men to come to the aid of the party
First Two Results:
    LowmiW HhZ7time for all good mea to comX to ths aid oV the p1ray
    Now is fhO P!me forjall gKod men to @ome to the a@d of F5e Nawty

```

The algorithm is, to some extent, tunable. You can have more or fewer glitches. You can change the set of glitch chars - whatever you'd like.