开发者

How to use string formats in C#?

I have three textboxes in my control,for hour, minute and second.

User can input the values in text boxes.

I want to return the combined value in a format like HHH:mm:ss, how can I do that ?

For example if user puts the values 4,3,45 it should be 004:03:45.

Please guide me to that, I tried with string.Format("{0:000}:{1:00}:{2开发者_运维百科:00}",ht,mt,st)

but it's not working, can I also use TimeSpan to achieve the same ?


This guy here is always a help: http://blog.stevex.net/string-formatting-in-csharp/

I just always end up coming back to that reference :)


My golden reference for C# String Formatting is SteveX's blog entry on the topic:

http://blog.stevex.net/string-formatting-in-csharp/

Should have the answer for you.


you can use string format for this purpose of string date time....... you can convert the time into string and then match it with the concatenated string from three text boxes....... i think this logic would work for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜