You can do this though:
using (IDisposable cmd = new SqlCommand(), con = (cmd as SqlCommand).Connection)
{
var command = (cmd as SqlCommand);
var connection = (con as SqlConnection);
//code
}
Perhaps that would be satisfactory to you.
More Related Contents:
- Type Checking: typeof, GetType, or is?
- Conditional operator cannot cast implicitly?
- Integer summing blues, short += short problem
- Nested using statements in C#
- Creating a Generic type instance with a variable containing the Type
- How To Change DataType of a DataColumn in a DataTable?
- Generics in C#, using type of a variable as parameter [duplicate]
- What is cool about generics, why use them?
- What is the best data type to use for money in C#?
- Why should you remove unnecessary C# using directives?
- Why do these division equations result in zero?
- When should I use “using” blocks in C#? [duplicate]
- C# use System.Type as Generic parameter
- Generic method multiple (OR) type constraint
- How to call generic method with a given Type object? [duplicate]
- How can I get the data type of a variable in C#?
- Is there a reasonable approach to “default” type parameters in C# Generics?
- .NET : How do you get the Type of a null object?
- Do I have to Close() a SQLConnection before it gets disposed?
- Finding the Concrete Type behind an Interface instance
- What are the differences between value types and reference types in C#? [duplicate]
- cast object with a Type variable
- Why can’t Double be implicitly cast to Decimal
- How to switch between “possible” type of an object? [duplicate]
- What to do when bit mask (flags) enum gets too large
- Immutable type and property in C#
- What’s the difference between ‘int?’ and ‘int’ in C#?
- PostgreSQL and C# Datatypes
- Why can’t I call an extension method as a static method when using static import?
- Why remove unused using directives in C#?