Comments in Visual Studio for Mac
Important
Visual Studio for Mac was retired on August 31, 2024 in accordance with Microsoft’s Modern Lifecycle Policy. While you can continue to work with Visual Studio for Mac, there are several other options for developers on Mac such as the preview version of the new C# Dev Kit extension for VS Code.
While debugging or experimenting with code, you might want to comment blocks of code either temporarily or long term.
To comment out an entire block of code:
- Select the code and select Toggle Line Comment(s) from the context menu
OR
- Use the
cmd + /
key binding on the selected code.
These methods can be used to comment and uncomment sections of code.
In C# files, additional levels of line comments can be added, which allows regions of codes to be commented and uncommented, while still preserving actual comments:
Comments are also useful for documenting code for future developers who might interact with it. It's done in the form of multiline comments, which are added in the following way in each language:
C#
/*
This is a multi-line
comment in C#
*/
F#
(*
This is a multi-line
comment in F#
*)