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 8890671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:33:19+00:00 2026-06-14T22:33:19+00:00

Does a base member initialization section exist in C#? I tried searching and searching

  • 0

Does a base member initialization section exist in C#? I tried searching and searching but kept coming up with questions regarding initializing the List class. The initialization list I am referring to looks like the example located here.

One reason for doing this is to initialize a constant in a class. I’m essentially trying to figure out if I can do the following:

public class A{
    private const string _name;
    public A(string name): _name(name){
         //stuff
    }
}

Again, I’m trying to do this in C#, not C++. Any thoughts?

  • 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-14T22:33:20+00:00Added an answer on June 14, 2026 at 10:33 pm

    No, C# does not support member initialization before constructor body the same way as C++ does. You can either initialize fields when they are declared or using normal assignament inside contructor body.

    The only 2 methods can be used at that position – call to contructor of base class and call to another contructor in the same class. You can check C# specification (i.e. http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf, section 17.10 Instance constructors) for details:

    constructor-declaration:
        attributesopt constructor-modifiersopt constructor-declarator constructor-body
    
    constructor-declarator:
       identifier ( formal-parameter-listopt ) constructor-initializer
    constructor-initializer:
      : base ( argument-listopt )
      : this ( argument-listopt )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Class DVD inherits class Media, has one more variable than the base class does.
does anybody know any css grid system with Base 980px Grid and Base 1003
Why does the following program crash? I have a base class whose destructor is
this code is the base of lexer , and it does the basic operation
I've just downloaded from SVN the DUnit2 code base. Does someone has compiled it
In C#, how does one obtain a reference to the base class of a
Possible Duplicates: C++ method only visible when object cast to base class?! Why does
An abstract base class (interface class) usually has all its member functions abstract. However,
Suppose I have a class Base which has a member variable A* my_hash. I
It appears to me that C++ does not allow member template specialization in any

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.