Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Remove unwanted space from string(C# begginer)

$
0
0
Hello

I have this method:
  public static string Puzzle(int upperBound) {
    string result = " ";
    for (int i = upperBound; i >=1; i--) {
      result = i*i+ " " + result;
      }
    return result;
      }


for upperBound = 7; result should be: "0 1 4 9 16 25 36 49" but in my case is "0 1 4 9 16 25 36 49 " it contains a space at the end of the string. I don't know how to remove only that space and still add a space between the letters. I would appreciate any ideas. Thanks!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>