TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paulo Amaral
NA
1
0
Doubt: turn base class method into private
Nov 10 2006 3:45 PM
Hi there, this is my first post in this forum. Here goes the question...
I want to create a custom array collection (
MyCollection
class) , to store objects of a custom class (
MyObject
class). Something like this:
public class MyCollection : System.Collections.ArrayList
{
}
Now, i want that only objects of the
MyObject
class can be added to the collection. So, i tryed to override the
Add
method, like this:
public class MyCollection : System.Collections.ArrayList
{
/* prevents external calling of this method */
private override int Add (object o)
{
return base.Add(o);
}
/* allows add only MyObject objects */
public int Add (MyObject o)
{
return base.Add(o);
}
}
I received the following error:
Virtul or abstract methods cannot be private.
So, i tried to use "
protected
" instead of "
private
", and i still have error:
cannot change access modifiers when overriding 'public' inherited member 'System.Collections.ArrayList.Add(object)'
I want that
only MyObjects objects can be included
in my custom collection.
Any solution? Thanks!
Reply
Answers (
0
)
Service waiting for external parameters
C# Developer