asp.net - Autogenerated number with the use of date and time c# -


having trouble on how going autogenerate number use of date , time. example, need generate kind of number, 16-9685 with, 16 = year , 9685 randomized , shown in textbox. tried 1 unfortunately, doesn't work. helping

var random = new random(system.datetime.now.year); int randomnumber = random.next(-1000, -1); textboxsesid.text = randomnumber.tostring(); 

// keep _r member, not local random _r = new random(); ...  // gen random number int rand = _r.next(1, 10000);  // "2016-" prefix string yearprefix = datetime.now.year + "-";  // remove first 2 digits of year prefix, "16-" yearprefix = yearprefix.substring(2);  // put year prefix random number textbox textboxsesid.text = yearprefix + rand; 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -