Reference:
Public Const COLUMN_MODEL_ORDER As String = MDL_ORDER.ColumnName
DataModel.Config.DefaultView
is a System.Data.DataView
What is this doing and how can I convert it?:
Dim ModelOrder As Integer = 1
Dim DataModel As New ProfileDataModel(New DBConnection, Me.ProfileID)
If DataModel.Config.DefaultView.Count > 0 Then
'what is this line doing?'
ModelO开发者_Go百科rder = CInt(DataModel.Config.DefaultView.Item(DataModel.Config.DefaultView.Count - 1)(Common.ProfileConfigs.COLUMN_MODEL_ORDER)) + 1
End If
- Operates on the last row in the dataview
- Pulls the value from the field whose name is represented in MDL_ORDER.ColumnName
- Converts it to an integer
- Adds one to it.
Others have posted how to convert this specific code, however, in general if you have some vb.net that you are unsure of how to code in C# simply grab Reflector and you can decompile it and browse in either language.
It takes the value of the last row's order column, converts it to an Integer, and adds 1 to it.
I figured it out, its indexers:
if (DataModel.Config.DefaultView.Count > 0)
{
ModelOrder = (int)DataModel.Config.DefaultView[DataModel.Config.DefaultView.Count - 1][Common.ProfileConfigs.COLUMN_MODEL_ORDER] + 1;
}
It looks like it's taking the value from last row in the DataView and the column defined by COLUMN_MODEL_ORDER and adding 1 to it.
it looks like Item is also an array, so it's accessing by index the first array then accessing by index the value of the second array
ModelOrder = Convert.ToInt32(DataModel.Config.DefaultView.Item[DataModel.Config.DefaultView.Count - 1][Common.ProfileConfigs.COLUMN_MODEL_ORDER]) + 1
精彩评论