By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

How can a property be Overridable and NotOverridable at the same time?

P: n/a
Hi,

I have a class that inherits from CollectionBase, and I'm trying to override
its Count property. As per the documentation, this property is overridable -
so I should be able to do this. So this is my code:

Public Overrides ReadOnly Property Count() As Integer
Get
End Get
End Property

The message I am getting is:
'Public Overrides ReadOnly Property Count() As Integer' cannot override
'Public Overridable NotOverridable ReadOnly Property Count() As Integer'
because it is declared 'NotOverridable'.
According to this, Count is both Overridable and NotOverridable? And the
NotOverridable is winning?

Can anyone shed any light on this?
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Your right. It should be either/or not both.
In any case you can shadow it.

Public Shadows ReadOnly Property Count() As Integer
Get
Set
End Property

--
Mick Doherty
http://dotnetrix.co.uk
"Marina" <so*****@nospam.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a class that inherits from CollectionBase, and I'm trying to override its Count property. As per the documentation, this property is overridable - so I should be able to do this. So this is my code:

Public Overrides ReadOnly Property Count() As Integer
Get
End Get
End Property

The message I am getting is:
'Public Overrides ReadOnly Property Count() As Integer' cannot override
'Public Overridable NotOverridable ReadOnly Property Count() As Integer'
because it is declared 'NotOverridable'.
According to this, Count is both Overridable and NotOverridable? And the
NotOverridable is winning?

Can anyone shed any light on this?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Jul 21 '05 #2

P: n/a
I spotted it :-)

Public Shadows ReadOnly Property Count() As Integer
Get
End Get <---
End Property

--
Mick Doherty
http://dotnetrix.co.uk
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Jul 21 '05 #3

P: n/a
Yes, the problem is, anything that excepts an icollection (like a grid or
something), will not be able to use the shadowed version.

Anyway, it seems like a stranger compiler and documentation bug - since
clearly this property is not overridable as the documentation claims.

Probably better off just implementing ICollection instead of inheriting
collectionbase at this point...

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:On**************@TK2MSFTNGP10.phx.gbl...
Your right. It should be either/or not both.
In any case you can shadow it.

Public Shadows ReadOnly Property Count() As Integer
Get
Set
End Property

--
Mick Doherty
http://dotnetrix.co.uk
"Marina" <so*****@nospam.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a class that inherits from CollectionBase, and I'm trying to

override
its Count property. As per the documentation, this property is

overridable -
so I should be able to do this. So this is my code:

Public Overrides ReadOnly Property Count() As Integer
Get
End Get
End Property

The message I am getting is:
'Public Overrides ReadOnly Property Count() As Integer' cannot override
'Public Overridable NotOverridable ReadOnly Property Count() As Integer'
because it is declared 'NotOverridable'.
According to this, Count is both Overridable and NotOverridable? And the NotOverridable is winning?

Can anyone shed any light on this?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.