字符串格式不适用于字符串 [英] String Format Does Not Works For string

查看:124
本文介绍了字符串格式不适用于字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个序列号,它是字符串类型。

这样;

String.Format( {0:#### - #### - #### - ####},1234567891234567);



我需要看喜欢这个,1234-5678-9123-4567;

这段代码不行吗?

你能帮助我?

解决方案

该语法需要一个int,试试这个:

  String.Format({0:####  -  ####  -  ####  -  ####},1234567891234567); 

编辑:如果您想在字符串上使用此语法,请尝试以下操作:

  String.Format({0:####  -  ####  -  ####  -  ####},转换。 ToInt64(1234567891234567))


I have a serial number which is String type.

Like This;

String.Format("{0:####-####-####-####}", "1234567891234567" );

I need to see Like This, 1234-5678-9123-4567;

Bu this Code does not work?

Can you help me?

解决方案

That syntax takes an int, try this:

String.Format("{0:####-####-####-####}", 1234567891234567);

Edit: If you want to use this syntax on a string try this:

String.Format("{0:####-####-####-####}", Convert.ToInt64("1234567891234567"))

这篇关于字符串格式不适用于字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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