ジェネレーターにこの関数があります。
Private Sub AddBoundedValue(ByVal boundedValue As Object, ByVal type As CodeTypeDeclaration, ByVal numericType As Type, name As String)
If boundedValue IsNot Nothing Then
Dim constant As New CodeMemberField(numericType, name)
constant.Attributes = MemberAttributes.Const Or MemberAttributes.Public
constant.InitExpression = New CodePrimitiveExpression(Convert.ChangeType(boundedValue, numericType))
type.Members.Add(constant)
End If
End Sub
開発者が「boundedValue」パラメーターに 10 進数を渡し、「numericType」パラメーターに 10 進数型を渡すと、次のコードが生成されます。
Public Const DollarAmountMaximumValue As Decimal = 100000
CodePrimitiveExpression オブジェクトのコンストラクターに渡されるデータ型は 10 進数ですが、生成されるコードは整数であり、暗黙的に変換されて 10 進数変数に格納されます。次のように、数字の後に「D」を付けて生成する方法はありますか?
Public Const DollarAmountMaximumValue As Decimal = 100000D
ありがとう。