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

Override vs Name Hiding

Hi all.
I am trying to figure out the differences between
overriding and hiding a method name.
The only difference i can see, is that with name hiding i can change
the method access level.
Are there any other differences?
Thanks, Sharon.
Nov 16 '05 #1
4 4134
Name hiding only works when the developer knows the true type of the
object. For instance, if you pass a NewArrayList that is derived from ArrayList
and try to new any of the methods, then classes that only know the object is
an ArrayList and weren't coded against NewArrayList will call the base methods
rather than the *new* methods.

Virtual inheritance gets over this by grabbing the highest override of a method
in the
list. If you instead override the method in the previous example, then even
code
that works on ArrayList will call the NewArrayList version of the method.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Sharon Tal" <ta*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi all.
I am trying to figure out the differences between
overriding and hiding a method name.
The only difference i can see, is that with name hiding i can change
the method access level.
Are there any other differences?
Thanks, Sharon.

Nov 16 '05 #2
> Are there any other differences?

Yes, there are:
1. If the member of the base class it is not virtual you cannot overrride,
so the only chance to give another implementation is using new(maybe with
the same access level);
2. The members declared using "new" do not have the polymorphims
characteristic; the overrided members do have it.

Ernest
"Sharon Tal" <ta*******@hotmail.com> wrote in message
news:#R**************@TK2MSFTNGP09.phx.gbl...
Hi all.
I am trying to figure out the differences between
overriding and hiding a method name.
The only difference i can see, is that with name hiding i can change
the method access level.
Are there any other differences?
Thanks, Sharon.

Nov 16 '05 #3
Sharon Tal <ta*******@hotmail.com> wrote:
I am trying to figure out the differences between
overriding and hiding a method name.
The only difference i can see, is that with name hiding i can change
the method access level.
Are there any other differences?


See http://www.pobox.com/~skeet/csharp/faq/#override.new

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
The difference is indeed significant.
Thanks :)
"Sharon Tal" <ta*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi all.
I am trying to figure out the differences between
overriding and hiding a method name.
The only difference i can see, is that with name hiding i can change
the method access level.
Are there any other differences?
Thanks, Sharon.

Nov 16 '05 #5

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

Similar topics

5
by: Darius | last post by:
I'm writing here in hopes that someone can explain the difference between the new and virtual/override keywords in C#. Specifically, what is the difference between this: public class Window {...
5
by: Mark Broadbent | last post by:
Oh yes its that chestnut again! Ive gone over the following (http://www.yoda.arachsys.com/csharp/faq/ -thanks Jon!) again regarding this subject and performed a few of my own tests. I have two...
11
by: songie D | last post by:
Does c# support overriding by name and not signature For instance I am building a custom collection class, that ca only take a certain type of object For this, I have added an override for add...
11
by: z_learning_tester | last post by:
Hello, yes another beginner question that I'm sure is obvious to many here :-) My book is so bad. Really. It uses the exact same example of code for using the new kw and for using virtual(in the...
3
by: Tom Jones | last post by:
I do not understand what is meant when someone states that a given method is "hidden" verses overriden. Would someone please provide a short example of both cases and why you might want to...
16
by: ssg31415926 | last post by:
Could someone explain the implications of the differences between using 'new' and 'override' on a member declaration, please. I checked out MSDN but it's not exactly written for the beginner. ...
3
by: methodios | last post by:
Hi Can someone help me straighten out my train of thought... I want to know what actually goes on behind the scene..step by step. Here is the code: ----------------- using System; ...
5
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This...
2
by: dolphin | last post by:
Hi everyone . I am confused about the different between override overload and hide. May be I have a wrong opinion, I always think that hide is very similar with override. Both of them call the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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...

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.