Well, I've been trying to randomize the lines of my richtextbox, and it's starting to bug me now as I'm using the random but it's not working... When I use this it'll repeat some lines multiple times, and not include some at all...
I've looked at: RichTextBox - sorting lines randomly
But it didn't help me at all.
RichtextBox rtb = new RichTextBox();
Random R = new Random();
int y;
rtb.Text = "";
for (int i = 0; i < richTextBox1.Lines.Length; i++)
{
y = R.Next(0, richTextBox1.Lines.Length);
rtb.Text = rtb.Text + richTextBox1.Lines[y].ToString() + "\r\n";
}
richTextBox2.Text = rtb.Text;
For example if I input,
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in aliquam enim. Proin at lacus magna. Nam bibendum, augue non semper fringilla, ante est interdum ipsum, a egestas urna dolor vel risus. Phasellus eget dui non augue pretium ullamcorper at ac tellus. Sed mattis risus sit amet metus dictum egestas. Phasellus tempus blandit enim, ac congue urna bibendum sed. Sed iaculis pulvinar dui vel tristique. Etiam justo metus, consequat in pellentesque eu, eleifend id nunc.
It gives me,
Sed mattis risus sit amet metus dictum egestas. Phasellus tempus blandit enim, ac congue urna bibendum sed. Nam bibendum, augue non semper fringilla, ante est interdum ipsum, a egestas urna dolor vel risus. Sed mattis risus sit amet metus dictum egestas. Phasellus tempus blandit enim, ac congue urna bibendum sed. Sed iaculis pulvinar dui vel tristique. Etiam justo metus, consequat in pellentesque eu, eleifend id nunc. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in aliquam enim. Proin at lacus magna.
Where one line is repeated, and one missed out... With longer text it occurs more often.
I haven't been doing C# too long, so sorry if this is simple. :/