Is there any way to define class properties using If statements with a public variable already declared?
Let's i have a class defined like this:
Public Class SomeDude
Property strName As String
Property datBirth As Date
End Class
Is there anyway to have sth like this:
Public Class SomeDude
Property strName As String
If strPublicVariable = "foo" then
Property datBirth As Date
Else
Property strBirth As String
End If
End Class
CodePudding user response:
No, You must have to declare type.
or you have to use Directives to make it compile time https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/directives/if-then-else-directives