|
|
|
Copyright © 2003-2007 ZeroC, Inc. |
18.9 Mapping for Constants
const bool AppendByDefault = true;
const byte LowerNibble = 0x0f;
const string Advice = "Don't Panic!";
const short TheAnswer = 42;
const double PI = 3.1416;
enum Fruit { Apple, Pear, Orange };
const Fruit FavoriteFruit = Pear;Public NotInheritable Class AppendByDefault
Public Const value As Boolean = True
End Class
Public NotInheritable Class LowerNibble
Public Const value As Byte = 15
End Class
Public NotInheritable Class Advice
Public Const value As String = "Don't Panic!"
End Class
Public NotInheritable Class TheAnswer
Public Const value As Short = 42S
End Class
Public NotInheritable Class PI
Public Const value As Double = 3.1416R
End Class
Public Enum Fruit
Apple
Pear
Orange
End Enum
Public NotInheritable Class FavoriteFruit
Public Const value As Fruit = Fruit.Pear
End ClassAs you can see, each Slice constant is mapped to a class with the same name as the constant. The class contains a member named value that holds the value of the constant.1
The mapping to classes instead of to plain constants is necessary because VB does not permit constant definitions at global or namespace scope.
|
|