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

  • Home
  • SEARCH
  • 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 6562647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:44:01+00:00 2026-05-25T13:44:01+00:00

Possible Duplicate: Why are private virtual methods illegal in C#? I have the following

  • 0

Possible Duplicate:
Why are private virtual methods illegal in C#?

I have the following code in C#, and Visual Studio is complaining in the Derived class that i cant declare a virtual/ abstract member private.. but i am not .. so does anyone have some ideas? Thanks

public class  Base
{
    private const string Name= "Name1";
    protected virtual string Member1
    {
    get{
       return Name;
       }
     }
}

public class Derived: Base
{
 private const string Name= "Name2";
 protected override string Member1
 {
  get{
     return Name;
     }
 }   
}
  • 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-05-25T13:44:02+00:00Added an answer on May 25, 2026 at 1:44 pm

    Unable to reproduce, having fixed the case of “Class” and provided method bodies:

    class Base
    {    
        protected virtual string Member1() { return null; }    
    }
    
    class Derived : Base
    {
        protected override string Member1() { return null; }   
    }
    

    This compiles with no warnings.

    If you were trying to declare fields as virtual, you’d get:

    Test.cs(11,30): error CS0106: The modifier ‘virtual’ is not valid for this item
    Test.cs(17,31): error CS0106: The modifier ‘override’ is not valid for this item

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

Sidebar

Related Questions

Possible Duplicate: Protected in Interfaces The following code snippet shows that an interface in
Possible Duplicate: Best way to define private methods for a class in Objective-C Hi,
Possible Duplicate: List<T> readonly with a private set I have a class as: public
Possible Duplicate: When do you use the “this” keyword? If I have the following
Possible Duplicate: .Net Changes the element IDs I have the following problem (I'll explain
Possible Duplicate: does these code has memory leakage?? static private ArrayList seriesColors = new
Possible Duplicate: Is this key-oriented access-protection pattern a known idiom? I have class A
Possible Duplicate: Undefined reference to vtable I have a class Student on the file
Possible Duplicate: JavaScript private methods I was kind of busy playing with jquery, Ext
Possible Duplicate: Changing graph feed to public and private Why is it that the

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.