Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perfect Final

Trying to convert int to string?

I'm trying to end the loop by reducing the int of the entry variable by 1 by calling parse. But, I keep getting a compiler error saying that I can't convert an int to a string.

Can you post your code so that we can take a look at what's going on?

Never mind, I actually figured out the problem. Thanks, though.

2 Answers

Andy Swinford
Andy Swinford
8,152 Points

The simplest way to accomplish this would be:

string myString = myNumber.ToString();
Jacob Bergdahl
Jacob Bergdahl
29,118 Points

You don't use Parse to convert an integer to a string, since an integer can always be turned into a string. You can convert an integer to a string like so:

string test = Convert.ToString(1);