如何连接名字和姓氏并在asp.net C#中显示标签 [英] how to concat first name and last name and display in label in asp.net C#

查看:71
本文介绍了如何连接名字和姓氏并在asp.net C#中显示标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何连接名字和姓氏并在asp.net C中显示标签#

---------------------- -------------------------------------------------- -





朋友们,我的项目基于asp.net c#。



在注册本网站时,用户将在注册表中输入他的名字和姓氏。



我想将其存储在会话中。

喜欢会话[用户名]



这样会显示标签,如



你好,Ubaid Rahman





请帮助谢谢你。

how to concat first name and last name and display in label in asp.net C#
-------------------------------------------------------------------------


hi friends my project is based on asp.net c#.

while registering to this website user will enter his first name and last name in Registration form.

I want to store this in session.
like session["username"]

so this will display with label like

Hi, Ubaid Rahman


Please help thank u.

推荐答案

试试:

Try:
Session["username"] = firstName + " " + lastName;
...
myLabel.Text = string.Format("Hi, {0}", Session["username"]);


试试这个

try this
Session["username"] = s3 = string.Format("{0} {1}", firstname, lastname);
Label1.Text = Session["username"];



谢谢


Thanks


HI,



As在上面的解决方案中提到你可以连接,还有另一种方法可以连接。





As mentioned in the above solution you can concatenate and there is another way to concatenate also.

Session["username"] = string.Concat(firstName , lastName);
myLabel.Text = Session["username"];





如需参考,请点击以下链接:

C# string.Concat

使用C#的最佳字符串连接方法是什么?



谢谢



For reference follow the following link:
C# string.Concat
What''s the best string concatenation method using C#?

Thanks


这篇关于如何连接名字和姓氏并在asp.net C#中显示标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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