473,396 Members | 1,789 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,396 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 3405
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.