Hello.
I provided a class, which derives from the class DataView.
The only thing, which I would like to do in this class am to overwrite the
Property COUNT.
I wars it however simply not. I get always following message from the
compiler, although COUNT of the DataView (according to MSDN) is virtual.
the element ' System.Data.DataView.Count.get ' cannot be overwritten,
because as virtually, abstract or do not overwrite it is marked
Can someone help me?
Thanks Thomas 7 2017
Thomas Kehl <t.****@heeb.com> wrote: I provided a class, which derives from the class DataView. The only thing, which I would like to do in this class am to overwrite the Property COUNT. I wars it however simply not. I get always following message from the compiler, although COUNT of the DataView (according to MSDN) is virtual.
I believe this is a bug in the documentation. If you look at the type
with ILDASM or Reflector, you'll see it's not actually virtual.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Jon,
when I look into System.Data with the Objectbrowser, I see, that the
definition of the Property is the fallowing:
public virtual new int Count [ get]
I think, I should be able to override it, should'nt I?
regards
thomas
"Jon Skeet" <sk***@pobox.com> schrieb im Newsbeitrag
news:MP************************@news.microsoft.com ... Thomas Kehl <t.****@heeb.com> wrote: I provided a class, which derives from the class DataView. The only thing, which I would like to do in this class am to overwrite
the Property COUNT. I wars it however simply not. I get always following message from the compiler, although COUNT of the DataView (according to MSDN) is virtual.
I believe this is a bug in the documentation. If you look at the type with ILDASM or Reflector, you'll see it's not actually virtual.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Thomas Kehl <t.****@heeb.com> wrote: when I look into System.Data with the Objectbrowser, I see, that the definition of the Property is the fallowing:
public virtual new int Count [ get]
I think, I should be able to override it, should'nt I?
I think it's taking that from the documentation rather than from the
assembly itself - it's certainly *not* virtual. The IL in ILDASM shows
..method public hidebysig newslot specialname virtual final
instance int32 get_Count() cil managed
and although "virtual" appears there, so does "final". It's all a bit
confusing, but I'm sure the upshot is that it's not virtual, I'm afraid
:(
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
The short answer is that MSDN and the object browser are wrong: the
property is not virtual.
The longer answer is that the DataView.Count property is non-virtual, and
is part of the implementation of the IComponent interface
(IComponent.Count). C# allows non-virtual interface implemenations, but
the CLR requires that all methods which implement interfaces be virtual.
So the compiler emits this in metadata as "newslot virtual final." So it
has the virtual flag set in metadata, but is final so that you cannot
override it.
-Mark
--
Mark Andersen, Visual C# Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
-------------------- From: Jon Skeet <sk***@pobox.com> Subject: Re: Problem to override a Property Date: Thu, 25 Sep 2003 19:28:25 +0100 Message-ID: <MP************************@news.microsoft.com> References: <ud**************@TK2MSFTNGP11.phx.gbl>
<MP************************@news.microsoft.com>
<OR**************@TK2MSFTNGP11.phx.gbl>MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: MicroPlanet Gravity v2.60 Newsgroups: microsoft.public.dotnet.languages.csharp NNTP-Posting-Host: cpc3-rdng5-6-0-cust143.winn.cable.ntl.com 81.103.154.143 Lines: 1 Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187372 X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
Thomas Kehl <t.****@heeb.com> wrote: when I look into System.Data with the Objectbrowser, I see, that the definition of the Property is the fallowing:
public virtual new int Count [ get]
I think, I should be able to override it, should'nt I?
I think it's taking that from the documentation rather than from the assembly itself - it's certainly *not* virtual. The IL in ILDASM shows
.method public hidebysig newslot specialname virtual final instance int32 get_Count() cil managed
and although "virtual" appears there, so does "final". It's all a bit confusing, but I'm sure the upshot is that it's not virtual, I'm afraid :(
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Mark Andersen [MSFT]" <ma****@online.microsoft.com> wrote in message
news:7k**************@cpmsftngxa06.phx.gbl... The short answer is that MSDN and the object browser are wrong: the property is not virtual.
The longer answer is that the DataView.Count property is non-virtual, and is part of the implementation of the IComponent interface (IComponent.Count). C# allows non-virtual interface implemenations, but the CLR requires that all methods which implement interfaces be virtual. So the compiler emits this in metadata as "newslot virtual final." So it has the virtual flag set in metadata, but is final so that you cannot override it.
So C# does not allow a method to be declared "virtual sealed", but will
generate the equivalent in IL for methods that are not declared virtual.
Interesting :-)
Mike Schilling <ms*************@hotmail.com> wrote: So C# does not allow a method to be declared "virtual sealed", but will generate the equivalent in IL for methods that are not declared virtual. Interesting :-)
Yes - as far as I can see, the CLR itself has some very odd terminology
in terms of "virtual" - it requires a method to be "virtual" to end up
being the resolution of a virtual call, even if it's not virtual in the
sense of being overridable (which is the sense the C# specification
uses). I don't think it's helping the discussion on what virtual means
:(
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Mike Schilling <ms*************@hotmail.com> wrote: So C# does not allow a method to be declared "virtual sealed", but will generate the equivalent in IL for methods that are not declared virtual. Interesting :-)
Yes - as far as I can see, the CLR itself has some very odd terminology in terms of "virtual" - it requires a method to be "virtual" to end up being the resolution of a virtual call, even if it's not virtual in the sense of being overridable (which is the sense the C# specification uses). I don't think it's helping the discussion on what virtual means :(
If I had to guess (and I do, since I'm too lazy to look it up :-), I'd
suspect that to the CLR "virtual" means "occupies a slot in the virtual
function table". The fact that the only difference between "virtual" and
"override" methods in C# is that the former generates the "newslot" CLR
keyword encourages me in this belief. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Omer van Kloeten |
last post by:
The Top Level Design:
The class Base is a factory class with a twist. It uses the Assembly/Type
classes to extract all types that inherit from it and add them to the list
of types that inherit...
|
by: jorfei |
last post by:
I have written a component with a property IPAdrress of type
System.Net.IPAddress. To ease the configuration of the component at design
time, I have written a type converter for the type...
|
by: SpookyET |
last post by:
I have thought that you can disable a set or a get when you override a
virtual property. I guess that I was wrong. The code below compiles and
doesn't throw the exceptions that I have expected. ...
|
by: Polo |
last post by:
Hi,
I have a Custom ExpandableTypeConverter (that show the property of a object
readonly)
Some properties of this sub object have the Browsable(false) attribute but
in the PropertyGrid these...
|
by: Jongmin |
last post by:
I met a problem when implementing IBindingList interface.
I made CustomerList class, copied from MSDN, to implement CollectionBase and
IBindingList.
My problem took place after setting...
|
by: Edward Diener |
last post by:
In C++ an overridden virtual function in a derived class must have the exact
same signature of the function which is overridden in the base class, except
for the return type which may return a...
|
by: michael |
last post by:
Hi.
I have a problem using the CollectioEditor.
In my custom control I have a public property that returns ItemList.
ItemList is inherited from CollectionBase and contains very simple
items...
|
by: Kristopher Wragg |
last post by:
Hi,
I'm having a problem with XMLSerializer, I have classes like the
following:
public abstract class EulerObject
{
private Rectangle rect;
private string guid = "";
|
by: priyamtheone |
last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have:
1) Initially all the cells of the dtp column should be...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |