![](/img/trans.png)
[英]How to concatenate string values and int values in one text box using rdlc report expression in c#
[英]How to concatenate two values into text box in c#?
我有兩個值,我想將這些值轉換為文本框。 我嘗試的方式如下所述
string time="00";
int Result ="02";
textresult.Text=result+' '+time;//first way error result
textresult.Text=(CAST(Result AS varchar(50))+' '+CAST(time AS varchar(50)))//second way..syntax error.
我需要在文本框中輸出02:00格式。 請建議一種解決這個問題的方法????
試試以下。
textresult.Text=string.Format("{0}:{1}",Result.ToString("D2"),time);
您的代碼報告語法錯誤,因為有。 看來你正在使用C#像sql語法!
嘗試這個:-
string time = "00";
int Result = 02;
textresult.Text=Result.ToString("D2") + ":" + time;
這可能有所幫助。
string time="00";
int Result =02;
textresult.Text = String.Format("{0}:{1}",Result.ToString("D2"),time);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.