• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Convert VB.NET to C#

Please convert following VB.NET codes to C#:

                Dim myDataSet As DataSet = Nothing
                myDataSet = GKCAccount.GetServerID(3)
                If myDataSet IsNot Nothing AndAlso myDataSet.Tables.Count > 0 AndAlso myDataSet.Tables(0).Rows.Count > 0 Then
                    catId = myDataSet.Tables(0).Rows(0)("ID").ToString()
                End If
0
Takeoutdinner
Asked:
Takeoutdinner
  • 5
  • 2
  • 2
1 Solution
 
sammySeltzerCommented:
DataSet myDataSet = null;
myDataSet = GKCAccount.GetServerID(3);
if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables(0).Rows.Count > 0) {
      catId = myDataSet.Tables(0).Rows(0)("ID").ToString();
}

You can use this tool to do it yourself:

http://converter.telerik.com/
0
 
Rajkumar GsSoftware EngineerCommented:
DataSet myDataSet = null;
myDataSet = GKCAccount.GetServerID(3);
if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0) {
	catId = myDataSet.Tables[0].Rows[0]["ID"].ToString();
}

Open in new window

http://www.developerfusion.com/tools/convert/vb-to-csharp/
0
 
Rajkumar GsSoftware EngineerCommented:
Ignore my post. It is already answered.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TakeoutdinnerAuthor Commented:
Hi,
I had this question with telerik, so RajkumarGS's advice is better for me.
But I still have a problem it with:
            DataSet myDataSet = null;
myDataSet = Reports.GetServerByID(3);
if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0 && (myDataSet.Tables[0].Rows[0]["Server"].ToString() = "Admin"))

Please correct my code.

Thanks,
0
 
Rajkumar GsSoftware EngineerCommented:
Change
= "Admin"
to
== "Admin"

0
 
Rajkumar GsSoftware EngineerCommented:
  DataSet myDataSet = null;
myDataSet = Reports.GetServerByID(3);
if (myDataSet != null && myDataSet.Tables.Count > 0 && myDataSet.Tables[0].Rows.Count > 0 && (myDataSet.Tables[0].Rows[0]["Server"].ToString() == "Admin"))

Open in new window

0
 
TakeoutdinnerAuthor Commented:
Thank you so much. It is the right solution!
0
 
Rajkumar GsSoftware EngineerCommented:
Glad I could help
Raj
0
 
sammySeltzerCommented:
You said his solution is better for you.

LOOK again at his solution and mine.

NO difference.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now