Question
How do you translate VB.NET's TypeOf operator and its CType function (as shown in the code below) to AVR for .NET?
If TypeOf e.Item Is GridDataItem Then Dim dataItem as GridDataItem = CType(e.Item. GridDataItem) ElseIf TypeOf e.Item is GridEditFormItem Then Dim editItem as GridEditFormItem = CType(e.Item, GridEditFormItem) EndIf
Answer
VB.NET's TypeOf
operator maps to AVR for .NET's *Is
operator (as it does C#'s is
operator). Use AVR for .NET's *As
casting operator in the place of VB.NET's CType
function. Also, AVR for .NET doesn't let you declare and assign a variable on one line like VB.NET or C# does. AVR needs you to explicitly declare dataItem
and editItem
before assigning values to them.
DclFld dataItem Type(GridDataItem) DclFld editItem Type(GridEditFormItem) If e.item *Is GridDataItem dataItem = e.Item *As GridDataItem ElseIf e.item *Is GridEditFormItem editItem = e.Item *As GridEditFormItem EndIf
Additional information
Product/Platform
ASNA Visual RPG for NET