I am using this code to generate a 8 digit unique number.
byte[] buffer = Guid.NewGuid().ToByteArray();
return BitConverter.ToUInt32(buffer, 8).ToString();
<
My first answer did not address the uniqueness problem. My second one does:
static int counter;
public static int GetUniqueNumber()
{
return counter++;
}
If you want to have unique numbers across app restarts, you need to persist the value of counter to a database or somewhere else after each and every GetUniqueNumber call.