Most C# style guides recommend against the /* ... */ commenting style, in favor of // or ///. Why is the former style to be avoided?
I always use // for actual COMMENTS, while I save the /* */ for code I temporarily do not want to run for debugging/development purposes.
By using only //, then you can be sure you can comment out a large block of lines/methods etc without nesting comments and making your compiler cry.
There are a few reasons to prefer // to /*.. */.
I think you comment as you want since most of us are commenting via shortcuts in Visual Studio.
I use ctr+K, ctrl+C
all selected rows are comented and ctr+K ctrl+U
to uncomment selected rows.
I wouldn't say I have a strong view against either - but IMO the biggest issue is that /*
and */
get messy if you have it nested, with the side effect that you can't copy/paste blocks around safely (quite).
You can too-easily end up with the wrong code commented/enabled, or can end up with it not compiling because you've ended up with a /* /* */ */
.
If you copy a block of //
around, no harm - just those lines remain commented.
I think /* */
will eventually go the way of the Dodo because in Visual Studio you can just select a block of code and hit CTRL-E,C to comment it out using the //
style.
One thing that /* */ can do that // can't is to comment an interior portion of a line. I'll sometimes use this to comment a parameter to a method where something isn't obvious:
point = ConvertFromLatLon(lat, lon, 0.0 /* height */ ) ;
In this case the constant, 0.0, being passed as the third parameter is representing height. Of course this might be better:
double height = 0.0;
point = ConvertFromLatLon(lat, lon, height) ;
(I'm more likely to use the /* */ intra-line temporarily, to just try out passing a specific value.)