Is this a bug?

  • Thread starter Thread starter lzj20021216
  • Start date Start date
L

lzj20021216

Guest
My codes look like these:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project_02
{
class Program
{
public static int[] nums = new int[5];
public static string[] numbers = new string[100];
static void Main(string[] args)
{
RandomNumbersCreators();
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Console.Write(numbers + " ");
}
Console.WriteLine();
}
Console.ReadKey();
for (int i = 0; i < 5; i++)
{
nums = 0;
}
for (int i = 0; i < 100; i++)
{
numbers = "";
}
Console.WriteLine();
Main(args);
}
public static void RandomNumbersCreators()
{
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 5; j++)
{
Random number = new Random();
int nNumber = number.Next(1, 10);
nums[j] = nNumber;
}
for (int k = 0; k < 5; k++)
{
numbers += nums[k].ToString();
}
}
}
}
}


If I try to run the following codes in Visual Studio 2019, I will always get results like these:

99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999

11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111
11111 11111 11111 11111 11111 11111 11111 11111 11111 11111

However, if I try to debug this application, it will show me the results they should always be

35262 35262 35262 35262 35262 35262 35262 35262 35262 35262
21318 21318 21318 21318 21318 21318 21318 21318 21318 21318
78593 78593 78593 78593 78593 78593 78593 78593 78593 78593
78537 78537 78537 78537 78537 78537 78537 78537 78537 78537
79233 79233 79233 79233 79233 79233 79233 79233 79233 79233
93921 93921 93921 93921 93921 93921 93921 93921 93921 93921
87896 87896 87896 87896 87896 87896 87896 87896 87896 87896
73112 73112 73112 73112 73112 73112 73112 73112 73112 73112
44781 44781 44781 44781 44781 44781 44781 44781 44781 44781
31241 31241 31241 31241 31241 31241 31241 31241 31241 31241

15268 15268 15268 15268 15268 15268 15268 15268 15268 15268
27213 27213 27213 27213 27213 27213 27213 27213 27213 27213
46457 46457 46457 46457 46457 46457 46457 46457 46457 46457
15949 15949 15949 15949 15949 15949 15949 15949 15949 15949
93617 93617 93617 93617 93617 93617 93617 93617 93617 93617
64234 64234 64234 64234 64234 64234 64234 64234 64234 64234
26771 26771 26771 26771 26771 26771 26771 26771 26771 26771
26952 26952 26952 26952 26952 26952 26952 26952 26952 26952
98137 98137 98137 98137 98137 98137 98137 98137 98137 98137
21556 21556 21556 21556 21556 21556 21556 21556 21556 21556

If I use .Net Core Tools, using command line dotnet run Project_02, I will got the similar results instead of many groups of the same numbers.

12163 12163 12163 12163 12163 12163 12163 12163 12163 12163
88336 88336 88336 88336 88336 88336 88336 88336 88336 88336
54238 54238 54238 54238 54238 54238 54238 54238 54238 54238
29213 29213 29213 29213 29213 29213 29213 29213 29213 29213
51448 51448 51448 51448 51448 51448 51448 51448 51448 51448
93514 93514 93514 93514 93514 93514 93514 93514 93514 93514
39383 39383 39383 39383 39383 39383 39383 39383 39383 39383
96937 96937 96937 96937 96937 96937 96937 96937 96937 96937
36675 36675 36675 36675 36675 36675 36675 36675 36675 36675
56963 56963 56963 56963 56963 56963 56963 56963 56963 56963

44393 44393 44393 44393 44393 44393 44393 44393 44393 44393
28364 28364 28364 28364 28364 28364 28364 28364 28364 28364
12767 12767 12767 12767 12767 12767 12767 12767 12767 12767
41566 41566 41566 41566 41566 41566 41566 41566 41566 41566
55547 55547 55547 55547 55547 55547 55547 55547 55547 55547
94528 94528 94528 94528 94528 94528 94528 94528 94528 94528
95894 95894 95894 95894 95894 95894 95894 95894 95894 95894
55255 55255 55255 55255 55255 55255 55255 55255 55255 55255
13951 13951 13951 13951 13951 13951 13951 13951 13951 13951
67442 67442 67442 67442 67442 67442 67442 67442 67442 67442


So is this really a bug or it has benn solved in higer versons?

Thanks for your replys!

Continue reading...
 
Back
Top