Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:17+00:00 2026-06-08T18:32:17+00:00

Possible Duplicate: “new” keyword in property declaration Pardon me if this is C# 101,

  • 0

Possible Duplicate:
“new” keyword in property declaration

Pardon me if this is C# 101, but I am trying to understand the code below:

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

namespace Generics
{
    class RabbitCollection : ArrayList
    {
        public int Add(Rabbit newRabbit)
        {
            return base.Add(newRabbit);
        }

        //collections indexer 
        public new Rabbit this[int index]
        {
            get { return base[index] as Rabbit; }
            set { base[index] = value; }
        }
    }
}

Why does the indexer have new in front of it? By the way, Rabbit is a class defined in another file. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:32:19+00:00Added an answer on June 8, 2026 at 6:32 pm

    Try removing new from the code and you should get a warning:

    RabbitCollection.this[int]’ hides inherited member
    ‘System.Collections.ArrayList.this[int]’. To make the current member
    override that implementation, add the override keyword. Otherwise add
    the new keyword.

    You may want to see new Modifier C#

    The new keyword explicitly hides a member inherited from a base class.
    When you hide an inherited member, the derived version of the member
    replaces the base-class version. Although you can hide members without
    the use of the new modifier, the result is a warning. If you use new
    to explicitly hide a member, it suppresses this warning and documents
    the fact that the derived version is intended as a replacement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C++'s “placement new” in the below code what does Line 3 represents,
Possible Duplicate: setTimeout and “this” in JavaScript I am trying to put a timeout
Possible Duplicate: “new” keyword in Scala Ive noticed that creating certain instances in Scala
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm trying to understand
Possible Duplicate: What does “(void) new” mean in C++? I'm not familiar with C++
Possible Duplicate: Creating an “object” of an interface I am new to Java. Based
Possible Duplicate: Cannot declare Public static final String s = new String(“123”) inside an
Possible Duplicate: C++: What is the printf() format spec for “float”? I am new
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm trying to create
Possible Duplicate: “using” keyword in java I'm transitioning from C# to java, so please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.