Convert Field to Property

Top  Previous  Next

 C#   VB.NET   VB6   VBA 

The Convert Field to Property feature allows you to easily convert a field (or selected group of fields) of a class such as:

[C#]

 

public int Count;

[VB.NET / VB / VBA]

 

Public Count As Integer

into a property such as:

[C#]

 

private int m_count;

 

public int Count

{

get

{

return m_count;

}

set

{

m_count = value;

}

}

[VB.NET]

 

Private m_count As Integer

 

Public Property Count() As Integer

 

Get

Return m_count

End Get

 

Set(ByVal value As Integer)

m_count = Value

End Set

 

End Property

[VB / VBA]

 

Private m_count As Integer

 

Public Property Get Count() As Integer
  Count = m_count
End Property

 
Public Property Let Count(ByVal Value As Integer)
  m_count = Value

End Property

Once you have put the cursor on the line with the field declaration (or selected the several lines with field declarations), MZ-Tools offers the following ways to convert it to a property:

  • The MZ-Tools | Convert Field To Property... menu.
  • The Convert Field To Property... menu entry on the context menu of a code window.
  • The Convert Field To Property button on the MZ-Tools - Main toolbar.
  • In Visual Studio 2015 and higher, the keyboard shortcut associated with the MZTools.ConvertFieldToProperty command.
  • In Visual Studio 2013 and lower, the keyboard shortcut associated with the MZTools8.ConvertFieldToProperty command.
  • In VB6 / VBA, the keyboard shortcut associated with the Convert Field to Property feature.

Then, the line under the cursor will be parsed and the proper values will be filled in the New Method / Property Assistant window. When you click the Insert button, the field declaration is converted to a property.

Remarks:

  • You can customize the type tags preferences for member variables in the Options window, Team Options tab, Type Tags section.

See Also:

New Method / Property Assistant

Type Tags Options

Keyboard Shortcuts Options