简体   繁体   English

String.Format不能按预期工作

[英]String.Format doesn't work as expected

Maybe its my machine, but this doesn't make any sense. 也许是我的机器,但这没有任何意义。

String.Format doesn't work. String.Format不起作用。 These two should technically equal, but do not. 从技术上讲,这两个应该相等,但不相等。 What's missing? 缺少了什么? I'm using ASP.NET 3.5 on Windows 7. 我在Windows 7上使用ASP.NET 3.5。

 string.Format("{0};{1};{2};{3};{4};{5};{7};{8};{9}"
                  , "711.01"
                  , "711.01"
                  , "711.01"
                  , "136.74"
                  , "136.74"
                  , "136.74"
                  , "136.74"
                  , "711.01"
                  , "711.01"
                  , "711.02 br ");

 //and
string.Join(";"
                  , new[]{"711.01"
                  , "711.01"
                  , "711.01"
                  , "136.74"
                  , "136.74"
                  , "136.74"
                  , "136.74"
                  , "711.01"
                  , "711.01"
                  , "711.02"}); 

You are missing {6} in the Format example. 您在Format示例中缺少{6}

"{0};{1};{2};{3};{4};{5};{7};{8};{9}"

should be 应该

"{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}"

As pointed out by Chris you have an extra br. 克里斯指出,您还有一个额外的兄弟。 You're also missing {6} from your string.format: 您的string.format还缺少{6}:

 string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}"
                     , "711.01"
                     , "711.01"
                     , "711.01"
                     , "136.74"
                     , "136.74"
                     , "136.74"
                     , "136.74"
                     , "711.01"
                     , "711.01"
                     , "711.02");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM