473,320 Members | 1,921 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,320 software developers and data experts.

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

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
3 3396
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Robin Becker | last post by:
Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker
0
by: Saradhi | last post by:
Hi All , I am using the Code model for Generating the VB code on the Fly. I am able to generate a new class with the Variables, Fields and Methods I want. Now What I want is the facility to...
7
by: Frank | last post by:
Hi, a question probably asked before, but I can't find the answers. Base class X, classes A, B and C inherit class X. In class A I do not want to inherit property (or function or method) P1....
27
by: Just Me | last post by:
I made a Usercontrol that must have AutoScroll set to true when it is used. So I set it to True in the Load event. However the property still shows in the properties window when the control is...
5
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
3
by: Marina | last post by:
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...
4
by: PJ6 | last post by:
I get this design-time error (below) when setting thus property in my inherited web control to 'True'. I've debugged the code running at design-time to double check to see that no exception was...
1
by: sonia.sardana | last post by:
First of all I want to ask dat,is it a valid keyword. I have read it from MSDN help. NotOverridable means that if we declare a method in base class with keyword NotOverridable , we cannot override...
2
by: C. Herzog | last post by:
Hi! I want to create a huge amount of classes. All classes have in common that the change of a property should fire an Change-Event and maybe do other things. I don't want to write thousand...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.