Int32.TryParse() or (int?)command.ExecuteScalar()

后端 未结 7 2220
既然无缘
既然无缘 2020-12-18 20:14

I have a SQL query which returns only one field - an ID of type INT.

And I have to use it as integer in C# code.

Which way is faster and uses less memory?

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 20:31

    int Result = int.Parse(Command.ExecuteScalar().ToString());
    

    will work in C#.

提交回复
热议问题