My goal is to have a property or function that returns different types of
returns with no initial arguments. For example
Public Class Something
Private sData as string
Private lData as long
Public Property X () as String
Get
return sData
End Get
Set (byVal Value as string)
sData = Value
end set
end Property
Public Property X () as Long
Get
return lData
End Get
Set (byVal Value as Long)
lData = Value
end set
end Property
end class
Then have my code simply have the correct data type and set it equal, i.e.
Dim sInfo as String = Something.X
When I compile the above code the error I get is Public Property X() as
String and Public Property as Long cannot overload each other because they
differ only by return types.
Now, the VAL function in VB.NET allows you to pass in a string and has two
possible return types: Double and Integer. I am to assume that this is
something that can only be done by the .NET code or am i missing a keyword
in the property statement? I would need to be able to do this in a function
as well; I have tried and gotten the same error as above.
Thank you