473,400 Members | 2,163 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,400 software developers and data experts.

Why doesn't this throw an exception?

Hi all,

Any ideas why the below code won't throw an exception? It appears that the
base Add method is being called, and not mine :-(

-- Console App --

using System;
using System.Collections.Generic;
using System.Text;

namespace RelationshipListTest
{
class Program
{
static void Main(string[] args)
{
ListTest<int> myList = new ListTest<int>();
myList.Add(1);
}
}

public class ListTest<T> : List<T>
{
new void Add(T item)
{
throw new NotImplementedException();
}
}
}
Nov 17 '05 #1
4 1184
Danny Tuppeny wrote:
Hi all,

Any ideas why the below code won't throw an exception? It appears that the
base Add method is being called, and not mine :-(
Your new Add method is private:
new void Add(T item)


Add the public access modifier, it should throw the exception then.

hth,
Max
Nov 17 '05 #2
"Markus Stoeger" <sp******@gmx.at> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Any ideas why the below code won't throw an exception? It appears that
the base Add method is being called, and not mine :-(


Your new Add method is private:
new void Add(T item)


Add the public access modifier, it should throw the exception then.


LOL!!!

I think I need more coffee!!

Thanks :)
Nov 17 '05 #3
I felt like a moron too for not seeing it! :)

--
Robert Jeppesen
Durius
http://www.durius.com/

"Danny Tuppeny" <gr****@dannytuppeny.commmmmm> wrote in message
news:43**********************@ptn-nntp-reader02.plus.net...
"Markus Stoeger" <sp******@gmx.at> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Any ideas why the below code won't throw an exception? It appears that
the base Add method is being called, and not mine :-(


Your new Add method is private:
> new void Add(T item)


Add the public access modifier, it should throw the exception then.


LOL!!!

I think I need more coffee!!

Thanks :)

Nov 17 '05 #4
"Robert Jeppesen durius (dot) com>" <robert<at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I felt like a moron too for not seeing it! :)


I guess it's what I get for not learning (Ctrl+C) & implementing (Ctrl+V)
someone elses code!
Nov 17 '05 #5

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

Similar topics

3
by: Kerri | last post by:
Hi, I am new to .NET In my Error Logic on my Aspx pages when an error happens it hits my catch statement where I throw an Exception. My question is : what is the difference between Thwo...
3
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
17
by: hplloyd | last post by:
Hi, I have a function that adds data to a database and I want to return true if the database was updated and false if there was a problem, so I am using a try... catch block... My problem is...
6
by: Arjen | last post by:
Hi, I'm reading the enterprise library documentation and there I see the throw statement. try { // run code } catch(Exception ex) {
12
by: Andrew Schepler | last post by:
When compiled with Visual C++ .NET 2003 (only), the program below aborts as though no matching catch clause is present. If the copy constructor of A is made public, it successfully catches the...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
9
by: Adam | last post by:
I was looking for a way to just catch any exception throw. Given the postings, it looks like catch(...) should do it, except it doesn't. Maybe C++ is suppose to work this way, or maybe this is a...
34
by: electrician | last post by:
Perl has it, Basic has it, Fortran has it. What is so difficult about creating a goto command for JavaScript. Just set up a label and say go to it.
3
by: Joris De Groote | last post by:
Hi, I use Adobe Acrobat to read tekst from PDF files. After that the file has been read, I move the file in a folder (using the date I got from the text I got from Acrobat). Now here is my...
8
by: Karsten Schramm | last post by:
Hi, when I run the following code: using System; namespace ConsoleApplication22 { class Program {
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: 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?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.