The requested page is not available for the requested platform. You are viewing the content for Default platform.

Initialize

Purpose

The Initialize code provider initializes the variable or the field with the default type value.

Availability

Available when the caret is on an initialization statement, and the initialization value is not specified.

Note

This code provider is available in C# and Visual Basic code.

How to Use

  • Place the caret on a variable or field.
Note

The blinking cursor shows the caret's position at which the Code Provider is available.

public string GetDefaultValue() {
    string str
    Console.WriteLine("Default value is {0}", str);
    return str;
}
  • Press Ctrl + . or Ctrl + ~ to invoke the Code Actions Menu, select Initialize from the menu and press Enter.

Initialize

After execution, the Code Provider initializes the variable or the field with the default type value.

public string GetDefaultValue() {
    string str = string.Empty;
    Console.WriteLine("Default value is {0}", str);
    return str;
}