INT型のIDという1つのフィールドのみを返すSQLクエリがあります。
そして、C#コードで整数として使用する必要があります。
どちらの方法がより速く、より少ないメモリを使用しますか?
int id;
if(Int32.TryParse(command.ExecuteScalar().ToString(), out id))
{
// use id
}
また
int? id = (int?)command.ExecuteScalar();
if(id.HasValue)
{
// use id.Value
}
また
int? id = command.ExecuteScalar() as int?;
if(id.HasValue)
{
// use id.Value
}