且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为学生创建自动生成ID?

更新时间:2022-10-14 23:39:43

你不能简单地按照你的算法吗?您只需要永久存储(例如通过序列化)最后生成的后缀。


检查方法只需传递参数year,bla bla并获取STUDENTID

 string GetObjectID(int sequence,string yr =14,string d =02)
{
string getZero =;
for(int i = 0; i< 5 - sequence.ToString()。Length; i ++)
{
getZero + =0;
}
返回yr + d + getZero + sequence;
}





这将为

返回1:140200001

10:140200010

适用于99:140200099

.....

for 999:140200999


i want to my student id example-140200001
Hear 14 is year 02 is fixcode it is a school id and generate id comming 00001 to 2,3,.....like that but '0000' is also fix digit number
note( In This ID-changeble number is yy its change in year wise and 123... coming as serial number wise.hear '020000' is fix code its not change in this id )
plz help me how to generat....?

i need - ist student id-140200001
then next student id generate-140200002
then next id generet-140200003
then 140200004...... like that

Cannot you simply follow your algorithm? You just need to permanently store (for instance via serialization) the last generated suffix.


Check a method just pass the parameter year, bla bla and get STUDENTID
string GetObjectID(int sequence, string yr = "14", string d = "02")
  {
      string getZero = "";
      for (int i = 0; i < 5 - sequence.ToString().Length; i++)
      {
          getZero += "0";
      }
      return yr + d + getZero + sequence;
  }



This will return like
for 1 : 140200001
For 10: 140200010
For 99: 140200099
.....
for 999: 140200999