0

Maybe its my machine, but this doesn't make any sense.

String.Format doesn't work. These two should technically equal, but do not. What's missing? I'm using ASP.NET 3.5 on Windows 7.

 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"}); 
2
  • 6
    You mean aside from the stray "br" in the first one? Feb 20, 2012 at 22:54
  • 1
    At the very least, show the resulting strings. Feb 20, 2012 at 23:17

2 Answers 2

10

You are missing {6} in the Format example.

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

should be

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

As pointed out by Chris you have an extra br. You're also missing {6} from your string.format:

 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");
1
  • 1
    It might be worth pointing out if you had ReSharper it would have dimmed the 6th variable showing you that you weren't referencing it anywhere in your code. Everyone ♥'s ReSharper.
    – akiller
    Feb 21, 2012 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.