NOTE. Is this not a duplicate of the equivalent of VB.NET C # string reduction? , This question is about how to have different permissions on the getter and setter for the automatic VB property; for example, a public getter and a private setter. This question is about the auto-property syntax (and does not mention this problem).
I am trying to convert the auto property ( public getter and private setter) from C # to VB.NET.
But after conversion, VB.NET maintains a private field.
C # code
class DemoViewModel { DemoViewModel (){ AddCommand = new RelayCommand(); } public ICommand AddCommand {get;private set;} }
Equivalent to VB.NET from Code Converter
Class DemoViewModel Private Sub New() AddCommand = New RelayCommand() End Sub Public Property AddCommand() As ICommand Get Return m_AddCommand End Get Private Set m_AddCommand = Value End Set End Property Private m_AddCommand As ICommand End Class
VB.NET code creates a private support field.
Is it possible to get rid of this back field in the source code (for example, C #)? How?
Without this function, the VB.NET source will have such redundancy.
Tilak source share