generate incremental serial number in csharp

To generate an incremental serial number in C#, we can use a loop to iterate through a range of values and increment a counter variable for each iteration. Here's an example:

main.cs
int startingNumber = 1000;
int numCount = 10;
for (int i = 0; i < numCount; i++)
{
    int serialNumber = startingNumber + i;
    Console.WriteLine("Serial number: {0}", serialNumber);
}
187 chars
8 lines

In this example, we start with a startingNumber of 1000 and generate 10 sequential serial numbers by incrementing the serialNumber variable for each iteration of the loop. The resulting numbers printed to the console will be:

main.cs
Serial number: 1000
Serial number: 1001
Serial number: 1002
Serial number: 1003
Serial number: 1004
Serial number: 1005
Serial number: 1006
Serial number: 1007
Serial number: 1008
Serial number: 1009
200 chars
11 lines

gistlibby LogSnag