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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:36:26+00:00 2026-05-30T23:36:26+00:00

I have two questions about static + const members and static classes. One: Why

  • 0

I have two questions about static + const members and static classes.

One: Why would you declare a class that has all static and const members and not make the class static?

I have been studying .net code in reflector as a learning exercise. The class I have been studying that demonstrates this design is the FormsAuthentication class. All of it’s members are marked static or const yet the class it’s self is marked public sealed The only non static member in the class is a default constructor with no implementation. Why has this class not been marked public static sealed?

My second question is regarding why the members in the FormsAuthentication class are declared as static. As I understand it there could be many HttpApplications running in the app’s AppDomain and all these HttpApplications would share the same FormsAuthentication classes’ static members.

Two: Doesn’t this cause a bottleneck? If so why is it designed like this?

  • 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-30T23:36:27+00:00Added an answer on May 30, 2026 at 11:36 pm

    The reason is that FormsAuthentication is a class that predates the static class feature. It was introduced in .Net 1.1, which didn’t have the concept of static classes. Since the class is working, and there’s no benefit to changing it now, its likely no one is going to revisit it to remove the private ctor and make it static instead of sealed.

    Its likely static as the auth can be thought of as a singleton. You’d not need more than one instance of FormsAuthentication in your application (though technically with a static class there is never an instance, but with FormsAuth there potentially can be one, you’d have to decompile to see). Since there’s no need to create more than one instance, static methods suffice. It does make unit testing code that relies on it more difficult, but at the time there wasn’t as much consideration given to unit testing. You can’t pass instances of static classes to methods, whereas with singletons you can.

    The only bottleneck is that there is likely locking behind the scenes, as .Net typically provides thread safety for static members. Realistically though this is unlikely to cause problems; it may have thread local storage as well, so it may not do any locking at all. You’d have to decompile it to be sure.

    It depends on whether or not there’s static data that must be locked to ensure thread safety. If there is, locking can cause some contention for a shared resouce as threads will wait for the critical section to unlock and even then only one thread will be allowed in, others will wait their turn. But you can also have static methods which ONLY use information from parameters or thread local storage variables, in which case there’s no syncronization issues involved, and the methods can be called independantly with no bottle neck.

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

Sidebar

Related Questions

So .... There are obviously many questions that all have been asked about Singletons,
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
So I have two questions about HashMap s in Java: What is the correct
I have two noobish questions about Flash, Actionscript, Flex etc. 1) With these technologies
I have two static (STATIC_MASS) SpaceManager sprites. One is a child of the other
I have two classes, a Teacher class and a Student class. In my program
sorry i have many questions about the lock/cache.=_=.. ->1. about cache, i know that
Two questions about attributes: When are attribute classes instantiated? When the type is first
I am wondering how you would approach this problem I have two Taxrates that
I have two questions, stemming from observed behavior of C# static methods (which I

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.