Questions tagged [static-class]

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

In object oriented programming a static class is a class whose members must be accessed without an instance of the class. Its members must be created as static.

90 questions
0
votes
1 answer

Are static variables inside static classes unique to the class?

I created some static utility methods that I use for caching objects. public static class CacheProductView { static object _lock = new object(); static string _key = "product-view"; public static IEnumerable Select() { …
dotnetnoob
  • 10,783
  • 20
  • 57
  • 103
0
votes
2 answers

Is it possible to make static class foreach enabled?

Say I have a class with a list like: static class Accounts { public static List Items; ... } I there a way to make it foreach enabled so that I can do foreach without referencing the Items list like: foreach(Account account in…
xnp
  • 51
  • 2
  • 6
0
votes
0 answers

Difference Between singleton class and a class with only static members?

EDIT: I want the difference between singleton class and a class with only static members. I don't want to compare the singleton class with the static inner class, because java doesn't allow static classes rather than static inner classes. A…
Venkatesh
  • 1,537
  • 15
  • 28
0
votes
1 answer

Static class or multiple object references

I am coding a MVC 5 internet application, and I have a question in regards to if I should use the exact same method in each of my classes, or use a static class with this method instead. Here is the method: public Account GetAccount(string…
Simon
  • 7,991
  • 21
  • 83
  • 163
0
votes
1 answer

Static dictionary call "System.TypeInitializationException"

I have a static class to hold a dictionary and 2 get methods to access it Here is my class: public static class ConfiguraCuadros { public static Dictionary>>>…
culebrin
  • 125
  • 1
  • 15
0
votes
1 answer

How do VB.NET static classes work?

I understood them to be modules, such as my little one: Public Module Config Public Property ImportSettings As ImportConfig Sub New() ImportSettings = ImportConfig.Read() End Sub End Module Yet, I cannot access ImportSettings.…
ProfK
  • 49,207
  • 121
  • 399
  • 775
0
votes
1 answer

Evaluate bool property from static class in aspx page

So i have something like: static Config class, which is used everywhere in the project, having a bool property let's say Property. So I want to find a way to set this property in the aspx markup.
vasil todorov
  • 145
  • 1
  • 11
0
votes
1 answer

How to make static class which updated itself? (Similar to Mouse)

Mouse, as you know it, is a static class. It has a static property called Mouse.Position. That property, is updated dynamically (binded to mouse, maybe??). (I've read the Mouse documentation in msdn) I need to build a same class with this…
Moses Aprico
  • 1,951
  • 5
  • 30
  • 53
0
votes
1 answer

Static class stored as a property

I have a static abstract class called State, it defines the abstract methods start() and update(), and then I have multiple classes which implement State. Now I want to create a class, let's call it StateMachine, that has a property called…
Setzer22
  • 1,589
  • 2
  • 13
  • 29
0
votes
3 answers

Is it good practice to forbid constructor in static-only class?

In the application I am working on, there are some classes with only static functions. These classes do not follow the Singleton pattern. Consider them just as "tools". Not real example: class MathHelper { public static function plus($num1,…
Hector Ordonez
  • 1,044
  • 1
  • 12
  • 20
0
votes
1 answer

issue with static class property in php

I am working on a simple anonymous login system and I have a Session class which looks like this:
Latheesan
  • 23,247
  • 32
  • 107
  • 201
0
votes
1 answer

Is static class similar to cache or session

Is it possible in asp.net web application(intranet) to use static class instead of Session, Cache, (or) Cookies ... Currently in my new project, i am using a static class and storing all the needed data across multiple pages in this class as…
0
votes
3 answers

Real life usage of Singleton and Static class c#

i do not want to know the difference between singleton and static class first of all. i like to know when people should use singleton class and when static class. in my apps i use static class for helper or utility method and use singleton for db…
Thomas
  • 33,544
  • 126
  • 357
  • 626
0
votes
1 answer

httpcontext with static class to store and retrieve session data

I want to store my global data till its inserted into DB. so, i want to implement a customer class which can handle creating and storing session values. So, below is my code. public static class SessionHelper { private static int custCode; …
Arjun
  • 533
  • 2
  • 9
  • 23
0
votes
4 answers

Trying to filter data in grid, receiving "Cannot create an instance of the static class" error

I am attempting to filter the items populated in a grid in the code behind. When I try to call my adapter from the data access layer, I am receiving the following error: Cannot create an instance of the static class…
WCD
  • 39
  • 2
  • 8