Reputation: 308
i have to create a text file having four rows,in each rows there will be two hundred zeros.If i create a loop and write it will take more time.How can i print stream of data in single loop.i used this code
for (int j = 0; j <= 599; j++)
{
if (j >= 0 && j <= 199)
{
if (j == 199)
writer.WriteLine("0");
else
writer.Write("0");
}
else if (j >= 200 && j <= 399)
{
if (j == 499)
writer.WriteLine("0");
else
writer.Write("0");
}
else if (j >= 400 && j <= 599)
{
}
}
Upvotes: 1
Views: 83
Reputation: 7496
I would create a "constant" first:
string line = new String('0', 200);
for (int i = 0; i < 4; i++)
{
writer.WriteLine(line);
}
Upvotes: 2