-5
  • I am making a login for voters using a control number for password.
  • I have made admin settings where i put in there the selection "maritime education" and "general education".
  • If maritime education, then the control number generated should start at 100, for the first three number then followed by random numbers and + IDnumber.. IDnumber consists of 5 digits.
  • Else if general education, then the control number generated should start at 101, then followed by random numbers + IDnumber.

How do i do it?

enter image description here

Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62

1 Answers1

3

All you need to determine is whether they chose Maritime or General, then append a random number and their Id Number to the end of it.

Random rand = new Random();
string startingDigits;
if(maritimeEducation)
{
    startingDigits = "100";
}
else
{
    startingDigits = "101";        
}

string controlNumber = string.Format("{0}{1}{2}", 
    startingDigits, rand.Next(10000, 99999).ToString(), IdNumber);
Dave Zych
  • 21,581
  • 7
  • 51
  • 66