Search code examples
vb.netclassmodelproperties

how to solve Auto-implemented properties cannot have parameters & Identifier expected in Property class/model in vb.net


I'm trying to solve Auto-implemented properties cannot have parameters & Identifier expected in class/model in vb.net.

because the database has field names like that so I have to set the name property in the class or model Please Guide me.

Thanks

 Public Class PivotSizeStocksin
        Public Property -() As Integer    'Identifier expected
        Public Property XS/SS() As Integer  'Auto-implemented properties cannot have parameters
        Public Property XXL/2L() As Integer 'Identifier expected
        Public Property XXXL/3L() As Integer 'Identifier expected
        Public Property XXXXL/4L() As Integer 'Identifier expected
    End Class

Solution

  • Get rid of the parentheses. They are used to specify parameters for properties. As the error message says, auto-implemented properties (those without explicit getter and setter) cannot have parameters.

    There are rules about what characters can be used in identifiers, i.e. names of types, members, etc. How could you use slashes and dashes in an identifier when it would then be impossible to differentiate between them and mathematical operators? You can only use letters, digits and underscores in an identifier and the first character cannot be a digit.