C# Cheat Sheet


  // Comments in C#
  
  // Single-line comments start with //
  // This is a single-line comment in C#
  
  // Multi-line comments start with /* and end with */
  /* 
     This is a multi-line
     comment in C#
  */
  
  /// <summary>
  /// XML Documentation comments start with ///
  /// They are used to provide documentation for types and members.
  /// </summary>
  
  // Example code with comments
  class Program
  {
      static void Main(string[] args)
      {
          // Single-line comment
          Console.WriteLine("Hello, World!"); // Output: Hello, World!
  
          /*
           * Multi-line comment
           * This will print a message to the console.
           */
          Console.WriteLine("Multi-line comment");
  
          // XML Documentation comment
          /// <summary>
          /// This method writes a message to the console.
          /// </summary>
          void PrintMessage()
          {
              Console.WriteLine("Printing message");
          }
  
          // Calling the method
          PrintMessage(); // Output: Printing message
      }
  }
  
© 2024 CheatsheetCoder, All Rights Reserved.