如何合并int no和用于生成新ID的字符串 [英] how to merge int no and string for making new ID

查看:101
本文介绍了如何合并int no和用于生成新ID的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何合并int no和用于生成新ID的字符串???
例如:-CO101,RE201
如何在查询中写???????????????????????

  int  num =  101 ;
字符串 s = " 

字符串 result = 字符串 .Format("  {0} {1}",s,num);

// 此处结果变为"CS101";  


Dircet U不能将int值合并为字符串,如果需要,可以使用Convert.Int32(string string)将字符串转换为int值;方法.

谢谢你


请看这个简单的例子

 声明  @ id   int  设置 @ id = 101
声明  @ strid   varchar ( 10 ) set  @ strid = '  CO'

选择  @ strid  + cast( @ id   as   varchar ( 10 ))作为 NewId 


可以.如果可以,请接受答案.


how to merge int no and string for making new ID????
example:-CO101,RE201
how to write in query????

解决方案

Since your question in marked as ASP.NET, I am assuming you want this in the code so here is the example

int num = 101;
string s = "cs"

string result = String.Format("{0}{1}",s, num);

//here result becomes "CS101"; 


Dircet U cann''t merge int value into string, if you want this you can convert string into int value using Convert.Int32(string string) ; method.

Thank u


please look this simple example

declare @id int set @id=101
declare @strid varchar(10) set @strid='CO'

select @strid + cast(@id as varchar(10)) as NewId


it will work.if it work accept as answer.


这篇关于如何合并int no和用于生成新ID的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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