Reputation: 77
Here is my sample VB.NET code that uses DirectCast
. I am having trouble converting it to C#.
Dim arr As ArrayList
If ViewState("SelectedRecords") IsNot Nothing Then
arr = DirectCast(ViewState("SelectedRecords"), ArrayList)
Else
arr = New ArrayList()
End If
Upvotes: 0
Views: 1228
Reputation: 4046
Equivalent C# code is
ArrayList arr = default(ArrayList);
if (ViewState["SelectedRecords"] != null) {
arr = (ArrayList)ViewState["SelectedRecords"];
}
else {
arr = new ArrayList();
}
Upvotes: 4