R
rlueneberg
I want to output a string of random integers with 20 rows and 20 cols
separated by comma.
The problem I am having is that it is always printing the same number
like below:
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyProjects
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = string.Empty;
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 20; j++)
{
Random r = new Random();
int RandomNumber = r.Next(0,20);
str = str + RandomNumber.ToString() + ",";
}
str = str + Environment.NewLine;
}
textBox1.Text = str;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
This is ultimate desired result:
9,9,17,1,12,16,0,11,5,9,13,17,8,12,7,18,2,5,9,4,
4,19,3,14,18,1,16,16,11,15,19,3,14,8,12,3,7,11,15,6,
0,4,8,19,3,7,1,12,16,0,4,15,19,13,17,8,12,16,10,11,
5,9,13,4,8,3,6,17,1,5,9,0,15,19,2,14,17,1,16,7,
11,15,6,10,13,8,12,3,7,11,2,6,0,11,15,19,3,17,1,12,
16,0,11,15,9,13,4,8,12,16,7,1,5,9,0,4,8,2,6,17,
1,5,16,0,15,18,9,13,17,12,12,7,11,2,6,9,4,8,19,3,
7,10,2,16,0,11,15,19,3,17,8,12,16,7,11,15,9,13,4,8,
12,6,7,1,5,16,0,4,18,2,13,17,1,12,16,10,14,5,9,13,
17,8,3,6,10,1,5,9,4,15,19,3,6,18,1,16,0,11,15,19,
13,14,8,12,16,7,11,5,9,0,4,8,12,3,17,1,5,16,0,4,
15,9,13,17,1,12,16,10,1,5,9,13,4,8,2,6,10,1,5,0,
0,15,18,2,13,17,12,16,7,11,15,18,10,4,8,12,3,7,11,5,
16,0,4,8,19,3,17,8,12,16,0,14,15,9,13,4,8,12,6,10,
1,5,9,0,4,18,2,6,17,1,5,16,11,14,18,2,13,17,12,3,
7,10,14,5,9,4,8,19,3,7,1,2,16,0,4,15,19,13,17,8,
12,16,0,11,5,9,13,4,8,12,6,17,1,5,9,0,4,18,2,6,
17,3,11,2,6,10,1,5,19,3,14,18,2,16,17,11,15,19,3,14,
8,12,3,7,11,15,6,0,4,8,19,3,7,1,12,16,0,4,15,19,
13,17,8,12,16,7,11,6,10,1,5,8,3,7,18,2,6,9,1,15,
The funny thing is that if I run the code line by line in debug mode I
can make it work. Please help...
Rod
separated by comma.
The problem I am having is that it is always printing the same number
like below:
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyProjects
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = string.Empty;
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 20; j++)
{
Random r = new Random();
int RandomNumber = r.Next(0,20);
str = str + RandomNumber.ToString() + ",";
}
str = str + Environment.NewLine;
}
textBox1.Text = str;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
This is ultimate desired result:
9,9,17,1,12,16,0,11,5,9,13,17,8,12,7,18,2,5,9,4,
4,19,3,14,18,1,16,16,11,15,19,3,14,8,12,3,7,11,15,6,
0,4,8,19,3,7,1,12,16,0,4,15,19,13,17,8,12,16,10,11,
5,9,13,4,8,3,6,17,1,5,9,0,15,19,2,14,17,1,16,7,
11,15,6,10,13,8,12,3,7,11,2,6,0,11,15,19,3,17,1,12,
16,0,11,15,9,13,4,8,12,16,7,1,5,9,0,4,8,2,6,17,
1,5,16,0,15,18,9,13,17,12,12,7,11,2,6,9,4,8,19,3,
7,10,2,16,0,11,15,19,3,17,8,12,16,7,11,15,9,13,4,8,
12,6,7,1,5,16,0,4,18,2,13,17,1,12,16,10,14,5,9,13,
17,8,3,6,10,1,5,9,4,15,19,3,6,18,1,16,0,11,15,19,
13,14,8,12,16,7,11,5,9,0,4,8,12,3,17,1,5,16,0,4,
15,9,13,17,1,12,16,10,1,5,9,13,4,8,2,6,10,1,5,0,
0,15,18,2,13,17,12,16,7,11,15,18,10,4,8,12,3,7,11,5,
16,0,4,8,19,3,17,8,12,16,0,14,15,9,13,4,8,12,6,10,
1,5,9,0,4,18,2,6,17,1,5,16,11,14,18,2,13,17,12,3,
7,10,14,5,9,4,8,19,3,7,1,2,16,0,4,15,19,13,17,8,
12,16,0,11,5,9,13,4,8,12,6,17,1,5,9,0,4,18,2,6,
17,3,11,2,6,10,1,5,19,3,14,18,2,16,17,11,15,19,3,14,
8,12,3,7,11,15,6,0,4,8,19,3,7,1,12,16,0,4,15,19,
13,17,8,12,16,7,11,6,10,1,5,8,3,7,18,2,6,9,1,15,
The funny thing is that if I run the code line by line in debug mode I
can make it work. Please help...
Rod