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

General Discussion

Kevin Patel
Kevin Patel
3,014 Points

C sharp coding conventions

Among coding C sharp coding conventions, is it important have a space between parentheses and a function in C#?

like so...

Random.Range (300f, 700f);

or

Random.Range(300f, 700f);

I have noticed that my instructor, Nick Pettit, has been using the first option but others online use C sharp and coding conventions among other programming languages use the second one.

1 Answer

Steven Parker
Steven Parker
231,110 Points

I always use no space for functions and methods, but a put a space between keywords (for, while, switch) and parentheses enclosing parameters they use. I consider this "best practice" coding style.

This happens to the be format used consistently throughout the MSDN C# Documentation pages.