Perhaps what you’re looking for is an Array
or List
. Both of these can contain a sequence of multiple values, which would allow you to do this, for example:
var resultArray = new[] {
sqlCmd2.ExecuteScalar().ToString(),
sqlCmd3.ExecuteScalar().ToString()
};
// Read results with resultArray[0], resultArray[1]
Another option is to assign each result to an object property:
var result = new {
OneResult = sqlCmd2.ExecuteScalar(),
OtherResult = sqlCmd3.ExecuteScalar()
};
// Read results with result.OneResult or result.OtherResult
1
solved Multiple if Result = [closed]