在MVC视图中自动增加字母数字ID [英] Auto increment alphanumeric id in MVC view

查看:164
本文介绍了在MVC视图中自动增加字母数字ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用mvc视图在我的应用程序中使用字母数字ID自动递增请求否



任何人都有任何代码或提示..



提前感谢




我尝试过:



i试图从一些知名网站找到代码或逻辑,但我没有找到任何匹配的代码......

i want to auto increment Request No in my application with Alphanumeric ID using mvc view

do anyone have any code or hint for it..

thanks in advance


What I have tried:

i tried to find code or logic from some of the well known sites, but i did not found any matching code...

推荐答案

尝试



try

static void Main()
        {

            string a = GetAutoNumber("1"); // PR001
            string a1 = GetAutoNumber("11");// PR011
            string a2 = GetAutoNumber("111");// PR111
            string a3 = GetAutoNumber("1111");// PR1111

        }
        public static string GetAutoNumber(string lastPRNo)
        {
            string prefix = "PR";
            string number = lastPRNo;
            if (lastPRNo.Length < 3)
            {
                number = "000" + lastPRNo;
                number = number.Substring(number.Length - 3, 3);
            }

            return prefix + number;
        }


这篇关于在MVC视图中自动增加字母数字ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆