Improve "Use String.Format"

2 posts, 1 answers
  1. Matthias Bibo
    Matthias Bibo avatar
    71 posts
    Member since:
    Mar 2010

    Posted 25 Nov 2013 Link to this post


    the the quick fix "Use String.Format" is very nice, but not very intelligent. Please improve the feature, that is really usable.

    Here is a sample:

    message = @"Es wurden " + (e.Result.ResultCount - e.Result.ErrorCount) + @" von " + e.Result.ResultCount + " Dokumenten erfolgreich generiert.\n";

    JustCode refactoring:
    message = string.Format("{0}{1}{2}{3} Dokumenten erfolgreich generiert.\n", @"Es wurden ", e.Result.ResultCount - e.Result.ErrorCount, @" von ", e.Result.ResultCount);

    Excpected refactoring:
    message = string.Format(@"Es wurden {0} von {1} Dokumenten erfolgreich generiert.\n",(e.Result.ResultCount - e.Result.ErrorCount), e.Result.ResultCount);

  2. Answer
    Zdravko avatar
    657 posts

    Posted 26 Nov 2013 Link to this post

    Hi Matthias,

    Thanks for your feedback.
    Indeed, the @ sign influences the expected output from the JustCode command, even though the output string from the string.Format  remains right.

    Just a note, your expected result won't display the new line "\n" and maybe this is the reason we arrange the string this way.

    I will log this for further investigation and fixing.
    Thanks for sharing it with us.

    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  3. DevCraft banner
Back to Top