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) Console I/O Variables

Autumn Fisher
PLUS
Autumn Fisher
Courses Plus Student 2,165 Points

How do I Initialize bookTitle with the title of my favorite book?

I'm sure there's more than one way to do it, but what's the most common way on how developers do it?

1 Answer

Alex Bratkovskij
Alex Bratkovskij
5,329 Points
String bookTitle =   "My book title";

Thing is, it is just a declaration of String variable and assigning it a value. There is only one way of doing so. However, there are different STYLES of writing a code, you can use camelCasing or snake_case, you can write methods with curly braces starting in line with method declaration

static void Main(){
   string someCode =  "here";
}
// or
static void Main()
{
   string some_code =  "here" ;
}
// or if you making a very small method
static void Main() { string someCode = "here" }

I've heard stories of competitions that were run at the beginning of programming era when competitors had to write the most unreadable code.

Hope my answer helped, Alex