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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:39:05+00:00 2026-06-10T11:39:05+00:00

Why can I call TheFakeStaticClass.FooConst , like it’s static, when it’s not declared static?

  • 0

Why can I call TheFakeStaticClass.FooConst , like it’s static, when it’s not declared static?

Are const fields converted to static fields at compile time? (I understand that you can’t change a const and hence you only need “one instance”. I’ve used many const’s before like Math.PI but never thought about before, and now I do and now I am curious.

namespace ConstTest
{
    class Program
    {
        class TheFakeStaticClass
        {
            public const string FooConst = "IAmAConst";
        }

        class TheRealStaticClass
        {
            public static string FooStatic = "IAmStatic";
        }

        static void Main()
        {
            var fc = TheFakeStaticClass.FooConst; // No error at compile time!
            var fs = TheRealStaticClass.FooStatic;
            var p = new Program();
            p.TestInANoneStaticMethod();
        }

        private void TestInANoneStaticMethod()
        {
            var fc = TheFakeStaticClass.FooConst;
            var fs = TheRealStaticClass.FooStatic;
        }
    }
}
  • 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-10T11:39:06+00:00Added an answer on June 10, 2026 at 11:39 am

    From Jon Skeet – Why can’t I use static and const together

    All constants declarations are implicitly static, and the C#
    specification states that the (redundant) inclusion of the static
    modifier is prohibited.

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

Sidebar

Related Questions

In Ruby I can call methods with array elements used as positional parameters like
I understand that I can call ToString().IndexOf(...), but I don't want to create an
Using a delegate I can call any function asynchronously. From the documentation I understand
I know I can call it whatever, but just like there is a convention
Let's say I can call a method like this: core::get() . What is the
I understand I can call window.print() when the page loads to load the print
in javascript i can call prompt like this var retVal = prompt(Enter the new
I can call variables 2 ways. One is just to do it like this:
we can call the Array method in the top level like this Array(something) that
Why can you call C/C++ functions like this: (&myAwesomefunction)(arg1,arg2,arg3...); Surely taking the address of

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.