C
Charles Law
In a VB.NET app, I can write
Dim s As String = 3.ToString
This is because 3 is of type Int32, which is a structure, which has a method
ToString.
I would also like to be able to write
Dim s As String = 3.ToPercent
by supplying my own implementation of ToPercent. If I could do this, then I
would be able to do what I ultimately wish to do, and that is write
something like the following:
Dim mc As New MyClass
Dim i As Integer
i = mc.Value
Textbox1.Text = mc.Value.ToPercent
I have tried to make Value of type MyValueClass, for example, which inherits
from Int32, but Int32 is not inheritable, so that is a non-starter. In any
case, the first assignment gives a compile time error because there is no
default property of MyValueClass, and I can't set one unless it takes
parameters (which it doesn't).
Can anyone suggest how this might be done?
TIA
Charles
Dim s As String = 3.ToString
This is because 3 is of type Int32, which is a structure, which has a method
ToString.
I would also like to be able to write
Dim s As String = 3.ToPercent
by supplying my own implementation of ToPercent. If I could do this, then I
would be able to do what I ultimately wish to do, and that is write
something like the following:
Dim mc As New MyClass
Dim i As Integer
i = mc.Value
Textbox1.Text = mc.Value.ToPercent
I have tried to make Value of type MyValueClass, for example, which inherits
from Int32, but Int32 is not inheritable, so that is a non-starter. In any
case, the first assignment gives a compile time error because there is no
default property of MyValueClass, and I can't set one unless it takes
parameters (which it doesn't).
Can anyone suggest how this might be done?
TIA
Charles