Hi all,
I am typically a VB.Net programmer, however a current project requires
me to work in C#. So I am attempting to better my understanding of C# by
converting an existing application. Im doing ok really, but the
following is bugging me.
What would the equivellent to this code be in C#:
For Each myDataRow as DataRow In myDataset.Tables(0).Rows
If myDataRow.Item("UserID") IsNot DBNull.Value Then
UserInfo.UserID = myDataRow.Item("UserID")
End If
Next
I tried using a online converter, but this gives me the following
foreach (DataRow myDataRow in myDataset.Tables(0).Rows) {
if (!object.ReferenceEquals(myDataRow.Item("UserID"), DBNull.Value))
{
UserInfo.UserID = myDataRow.Item("UserID");
}
}
This seems very long winded. Is this the correct way to do what I aim to do?
Regards
Mick