C# - what's new in C# 1.1?

You will need Visual Studio .NET 2003 or higher. (Released April 2003).


Summary:


1) #line directive


Changes how the compiler reports line numbers. Useful for generated code where you want to preserve line numbers and file names, so that clicking on an error in the Error List window jumps to the original file, and not the generated one.


  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace t1
  {
    class Program
    {
        static void Main(string[] args)
        {
  #line 200
            int i; // The variable 'i' is declared but never used. Line 200. Program.cs
  #line 300 "MyFile.cs"
            int j; // The variable 'j' is declared but never used. Line 300. TestFile.cs
  #line default
            int k; // The variable 'j' is declared but never used. Line 16. Program.cs
  #line hidden
            Console.WriteLine("Hidden line");
  #line default
            Console.WriteLine("Normal line");
        }
    }
  }
  

2) xml doc comments


XML comments start with three slashes ///.
The text must be valid XML. It will be used by intellisense, and can be used to generate an XML documentation file using the /doc compiler option.


  /// <summary>
  /// Determines whether this <see cref="RelayCommand"/> can execute in its current state.
  /// </summary>
  /// <param name="parameter">
  /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
  /// </param>
  /// <returns>true if this command can be executed; otherwise, false.</returns>
  public bool CanExecute(object parameter)
  {
      return _canExecute == null ? true : _canExecute();
  }
  

csc command line: csc.exe /doc:bin\Debug\test1.xml


  <?xml version="1.0"?>
  <doc>
    <assembly>
        <name>test1</name>
    </assembly>
    <members>
        <member name="M:test1.Program.CanExecute(System.Object)">
            <summary>
            Determines whether this <see cref="!:RelayCommand"/> can execute in its current state.
            </summary>
            <param name="parameter">
            Data used by the command. If the command does not require data to be passed, this object can be set to null.
            </param>
            <returns>true if this command can be executed; otherwise, false.</returns>
        </member>
    </members>
  </doc>
  

Ads by Google



Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath