Table of Contents Previous Next
Logo
Client-Side Slice-to-Visual Basic Mapping : 18.9 Mapping for Constants
Copyright © 2003-2007 ZeroC, Inc.

18.9 Mapping for Constants

Here are the constant definitions we saw in Section 4.9.5 on page 97 once more:
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;
Here are the generated definitions for these constants:
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 Class
As 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

1
The mapping to classes instead of to plain constants is necessary because VB does not permit constant definitions at global or namespace scope.

Table of Contents Previous Next
Logo