473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Where is the .Dispose?

Ok, this is not a real problem but I am just really curious. I can see
that IDataReader/SqlDataReader implements the IDisposable interface. So
why can't I see the .Dispose method in the intellisense for an
instantiated SqlDataReader object?

Thanks.
Jul 1 '06 #1
7 1390
"Frank Rizzo" <no**@none.com> a écrit dans le message de news:
es**************@TK2MSFTNGP04.phx.gbl...

| Ok, this is not a real problem but I am just really curious. I can see
| that IDataReader/SqlDataReader implements the IDisposable interface. So
| why can't I see the .Dispose method in the intellisense for an
| instantiated SqlDataReader object?

Because Dispose() is part of IDisposable and if any interface is implemented
explicitly, it is not visible on the class, only on the interface

public class MyClass : IDisposable
{
...

void IDisposable.Dispose()
{
// this is not visible to the class
}
}

{
MyClass mc = new MyClass();

(mc as IDisposable).Dispose();

}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 1 '06 #2
Its inherited from DbDataReader and is marked as
[EditorBrowsable(EditorBrowsableState.Never)] which means it will never show
up in intelleisense.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Frank Rizzo" <no**@none.com> wrote in message
news:es**************@TK2MSFTNGP04.phx.gbl...
Ok, this is not a real problem but I am just really curious. I can see
that IDataReader/SqlDataReader implements the IDisposable interface. So
why can't I see the .Dispose method in the intellisense for an
instantiated SqlDataReader object?

Thanks.

Jul 1 '06 #3
Ah yes we should have been clear about which version of the framework. 1.x
does use an explicit interface implementation!

Cheers,

Greg
"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Frank Rizzo" <no**@none.com> a écrit dans le message de news:
es**************@TK2MSFTNGP04.phx.gbl...

| Ok, this is not a real problem but I am just really curious. I can see
| that IDataReader/SqlDataReader implements the IDisposable interface. So
| why can't I see the .Dispose method in the intellisense for an
| instantiated SqlDataReader object?

Because Dispose() is part of IDisposable and if any interface is
implemented
explicitly, it is not visible on the class, only on the interface

public class MyClass : IDisposable
{
...

void IDisposable.Dispose()
{
// this is not visible to the class
}
}

{
MyClass mc = new MyClass();

(mc as IDisposable).Dispose();

}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Jul 1 '06 #4
"Greg Young" <dr*******************@hotmail.com> a écrit dans le message de
news: %2****************@TK2MSFTNGP03.phx.gbl...

| Ah yes we should have been clear about which version of the framework. 1.x
| does use an explicit interface implementation!

Ah, OK Greg, I assumed explicit and didn't realise it had changed. Thanks.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 1 '06 #5
2.0

..method public hidebysig newslot virtual final instance void Dispose() cil
managed
{
.custom instance void
[System]System.ComponentModel.EditorBrowsableAttribute::.c tor([System]System.ComponentModel.EditorBrowsableState)
= ( int32(0x00000001) )
.maxstack 2
L_0000: ldarg.0
L_0001: ldc.i4.1
L_0002: callvirt instance void
System.Data.Common.DbDataReader::Dispose(bool)
L_0007: ret
}

What's interesting is that in VS 2005 it still shows up for me even though
it shouldn't per the documentation unless I am missing something some where
else
http://msdn2.microsoft.com/en-us/lib...attribute.aspx
the value loded here is System.ComponentModel.EditorBrowsableState.Never.
Can't quite figure out why (I have even tried an example re-implementing the
interface as it does).

---library assembly
public class Class1 : IAge{
int ageval;
[EditorBrowsable(EditorBrowsableState.Never)]
public int Age {
get { return ageval; }
set {
if (!ageval.Equals(value)) {
ageval = value;
}
}
}
}
public class Class2 : Class1, IAge {
}
public interface IAge {
int Age {
get;
}
}

--- main assembly
class Program {
static void Main(string[] args) {
Class2 f = new Class1();
//no f.age
}
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
"Greg Young" <dr*******************@hotmail.com> a écrit dans le message
de
news: %2****************@TK2MSFTNGP03.phx.gbl...

| Ah yes we should have been clear about which version of the framework.
1.x
| does use an explicit interface implementation!

Ah, OK Greg, I assumed explicit and didn't realise it had changed. Thanks.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Jul 1 '06 #6
If you're in C#, you can set the IDE to basically show you everything,
meaning that those Browsable attributse are mostly ignored as far as
intellisense goes.

Greg Young wrote:
2.0

.method public hidebysig newslot virtual final instance void Dispose() cil
managed
{
.custom instance void
[System]System.ComponentModel.EditorBrowsableAttribute::.c tor([System]System.ComponentModel.EditorBrowsableState)
= ( int32(0x00000001) )
.maxstack 2
L_0000: ldarg.0
L_0001: ldc.i4.1
L_0002: callvirt instance void
System.Data.Common.DbDataReader::Dispose(bool)
L_0007: ret
}

What's interesting is that in VS 2005 it still shows up for me even though
it shouldn't per the documentation unless I am missing something some where
else
http://msdn2.microsoft.com/en-us/lib...attribute.aspx
the value loded here is System.ComponentModel.EditorBrowsableState.Never.
Can't quite figure out why (I have even tried an example re-implementing the
interface as it does).

---library assembly
public class Class1 : IAge{
int ageval;
[EditorBrowsable(EditorBrowsableState.Never)]
public int Age {
get { return ageval; }
set {
if (!ageval.Equals(value)) {
ageval = value;
}
}
}
}
public class Class2 : Class1, IAge {
}
public interface IAge {
int Age {
get;
}
}

--- main assembly
class Program {
static void Main(string[] args) {
Class2 f = new Class1();
//no f.age
}
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
"Greg Young" <dr*******************@hotmail.coma écrit dans le message
de
news: %2****************@TK2MSFTNGP03.phx.gbl...

| Ah yes we should have been clear about which version of the framework.
1.x
| does use an explicit interface implementation!

Ah, OK Greg, I assumed explicit and didn't realise it had changed. Thanks.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 3 '06 #7
have not changed any .. my own code hides properly.

"Andy" <aj*****@alum.rit.eduwrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
If you're in C#, you can set the IDE to basically show you everything,
meaning that those Browsable attributse are mostly ignored as far as
intellisense goes.

Greg Young wrote:
2.0

.method public hidebysig newslot virtual final instance void Dispose() cil
managed
{
.custom instance void
[System]System.ComponentModel.EditorBrowsableAttribute::.c tor([System]System.ComponentModel.EditorBrowsableState)
= ( int32(0x00000001) )
.maxstack 2
L_0000: ldarg.0
L_0001: ldc.i4.1
L_0002: callvirt instance void
System.Data.Common.DbDataReader::Dispose(bool)
L_0007: ret
}

What's interesting is that in VS 2005 it still shows up for me even though
it shouldn't per the documentation unless I am missing something some
where
else
http://msdn2.microsoft.com/en-us/lib...attribute.aspx
the value loded here is System.ComponentModel.EditorBrowsableState.Never.
Can't quite figure out why (I have even tried an example re-implementing
the
interface as it does).

---library assembly
public class Class1 : IAge{
int ageval;
[EditorBrowsable(EditorBrowsableState.Never)]
public int Age {
get { return ageval; }
set {
if (!ageval.Equals(value)) {
ageval = value;
}
}
}
}
public class Class2 : Class1, IAge {
}
public interface IAge {
int Age {
get;
}
}

--- main assembly
class Program {
static void Main(string[] args) {
Class2 f = new Class1();
//no f.age
}
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
"Greg Young" <dr*******************@hotmail.coma écrit dans le message
de
news: %2****************@TK2MSFTNGP03.phx.gbl...

| Ah yes we should have been clear about which version of the framework.
1.x
| does use an explicit interface implementation!

Ah, OK Greg, I assumed explicit and didn't realise it had changed.
Thanks.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer

Jul 4 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: faktujaa | last post by:
Hi All, A small confusion. I have defined a connection class that has System.Data.IDbConnection as a member variable and implements IDisposable interface. I have implemented Dispose method to call...
4
by: RiteshDotNet | last post by:
..net Frame work 1. Dispose Method what it does ? A. who its call / when it calls ? B. Is it fire automatically ? c. When dispose method is call what it does ? D. Release a Object from memory or...
5
by: ypul | last post by:
the code below given is connection class ... now I want to use the connection in another class , by using the getConnection method. where should I call con.dispose() ? in connection class or...
7
by: Microsoft | last post by:
I'm not sure where to physically place my subroutines in vb.net I get namespace and not declared errors... Imports System Imports System.Management Public Class Form1
156
by: Dennis | last post by:
Ok, I'm trying to dispose of every object that I create that has a dispose method based on advice from this newsgroup. However, I'm not sure how to dispose of the following object that was created...
46
by: clintonG | last post by:
Documentation tells me how but not when, why or where... <%= Clinton Gallagher http://msdn2.microsoft.com/en-us/library/saxz13w4(VS.80).aspx
5
by: Michael.Suarez | last post by:
Suppose I have a button on a form that opens up another form. the code in the buttons click event is: frmMyCustomForm frm = new frmMyCustomForm (); frm.ShowDialog(); frm.Dispose(); The...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
4
by: JS | last post by:
I have an application with many user controls and forms which display measurements in whatever the current unit system is. The current unit system is kept in my 'Units' static class as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.