What is the difference between ///
and #region ...#endregion
statements in c#? Which one the best?
A region is used to collapse a large area of code and the // is used to add notes without the computer reading it.
#region your large code
loads of code in this area.
#endregion
//This is just a note that the computer won't read.
#region isn't a comment statement at all. It's for marking sections of code. ///
is for documentation comments.
/// is for XML comments while region in not for commenting but for grouping code section together.
#region
makes your code readable/maintainable/ more organized
///
documents code!
/// is used to insert XML Comments in your code. Xml comments allow you to build an output Xml file from you project: This file is later used by Visual Studio to show you intellisense tooltip with the comments you inserted. Moreover, you can use eit to build your own documentation. See here an article about how to build documentation from your source code Xml comments
#region is used to organize your code. It is only useful within IDE which understand it (VS), allowing you to collapse or expand every region of code you define with #region/#endregion
Completely different things, one is for commenting/documentation, the other for hiding code.
XML Comments (///)
#Region