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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:24:35+00:00 2026-06-02T17:24:35+00:00

In Objective-C (probably in C too) I can have a header file which can

  • 0

In Objective-C (probably in C too) I can have a header file which can contain just anything from macros to constants. And any class (actually the file it resides) that imports that header file can see and use whatever there is declared. Isn’t there a similar way to do this in C#? I have not found anything helpful so far. What I can do in C# is have a collection of static classes each having constant fields in them. But when I want to access those constants I have no other way but say Classname.ConstantName. That Classname part is really inconvenient.

  • 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-02T17:24:38+00:00Added an answer on June 2, 2026 at 5:24 pm

    You can make your life a little easier by specifying an alias for your class name:

    using G = MyNamespace.MyClassContainingGlobalConstants;
    
    ...
    
    var x = G.MyConstant;
    

    Apart from that, I’m not aware of any C# feature that would allow you to access static class members without some kind of class name. (BTW, VB.NET has Modules for this purpose.)

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

Sidebar

Related Questions

another objective c question for you. Probably a simple one too... In my viewDidLoad
another Objective-C one for you, probably pretty obvious but I have been at this
I just told Xcode to compile everything as Objective-C++ and now I have errors
I'm relatively new to Objective-C + Quartz and am running into what is probably
First of all, I'm new to objective-c programming so I've probably made some mistakes
Objective: In support of a Windows Service that may have multiple instances on a
Objective: My script will download a remote file upon form submission, since the file
Objective C is new for me. How can I change the font of a
This is probably a common Objective-C question reported by Java coders, but I don't
This is probably a completely stupid question, but i'm pretty new at objective-C and

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.