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# Help

Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in alphabetical order, and displays the sorted words separated by spaces.

Write a Main() to test this funciton. The SortAndDisplayWordsmethod will be tested with one, two, five, and ten words.

I don't really understand the syntax behind doing this I thought maybe you use .Sort but i am stuck.

1 Answer

Steven Parker
Steven Parker
231,261 Points

You might indeed make use of the "Sort" method, but you're going to need a bit of "boilerplate" for the program and method structure, to handle a variable argument list, and the testing extensions. Are you comfortable starting with that part of the code? Once you get the basic framework, you can post your code when you need help with specific issues like sorting.

This doesn't sound like a Treehouse course exercise. Were you given some reference examples leading up to this task where this came from?

This is an assignment that i got out of my textbook is that ok to post on here if i need help ?

Steven Parker
Steven Parker
231,261 Points

Sure, but I'm hoping they didn't just "throw you in the deep end to see if you can swim". Do you have some templates to use and/or can you build the "boilerplate" code to get started?

They threw me in the deep end it has been like that for a while I honestly need better help with this stuff. As for boilerplate I have no idea what that is.

Steven Parker
Steven Parker
231,261 Points

I don't know how this would fit into your schedules, but the C# track here would be a way to learn those skills. And "boilerplate" is the basic program structure. All the stuff all programs have in common no matter what they do.