
Originally Posted by
LarryChen
Thanks. I thought int can be converted to IDisposable implicitly.
Take a look at the definition for int (or any value type) in MSDN. To determine if an object has implemented IDisposable, walk up the inheritance hierarchy and see if IDisposable is declared anywhere under the syntax section.
For example, the syntax for int (doesn't implement IDisposable):
Code:
[SerializableAttribute]
[ComVisibleAttribute(true)]
public struct Int32 : IComparable, IFormattable,
IConvertible, IComparable<int>, IEquatable<int>
Syntax for SqlConnection (does implement IDisposable)
Code:
public sealed class SqlConnection : DbConnection,
ICloneable
Jumping up a level to inspect DbConnection yields
Code:
public abstract class DbConnection : Component,
IDbConnection, IDisposable