static

What is the point of "static new" modifier for a function?

Today, I found something in legacy code. It has "static new" for one function. It looks like this. class Foo { public static void Do() { Console.WriteLine("Foo.Do"); } } class Bar: Foo { public static new void Do() { Console.WriteLine("Bar.Do"); } } I don't understand the static new modifier fo...

static methods fine in debug but throwing TypeInitializationException in release

banging my head on this one. I have a static method with fields in a class similar to this: public MyClass { private static string m_myString; public static MyClass() { m_myString = "hello world"; } public static void MyUsefulMethod(Foo bar) { DoStuffTo(bar); } } In Debug mode, I have no issue but...

static members and boost serialization

I'm using Boost.Serialization to archive the contents of a class. One of the member variables is a static std::vector. Archiving and restoring goes fine, but I was kind of hoping the library would save static members only once, it appears that, judging by the filesize, the static members are fully saved for each archived instance. This...

Scope of static inner class in ASP.NET

I am unsure about the scope of one static inner class of a non-static class. In the lines below, would the variable DataContextCreator.Instance (part of a Singleton pattern) point to the same PDataContext instance for all Page objects/page requests or would each object have its own instance? public class Page : System.Web.UI.Page { ...

Templated assignment operator: valid C++?

Just a quick and simple question, but couldn't find it in any documentation. template <class T> T* Some_Class<T>::Some_Static_Variable = NULL; It compiles with g++, but I am not sure if this is valid usage. Is it? ...

Setting a header in apache

I'm trying to serve static files for download in a django application, I figured that I'd put the static files in /media/files and have Apache set the content-type header to application/octet-stream (the files to download are going to be word files but I'll work out the details later). To do this I activated mod_headers and then in the ...

Static compilation in the .NET world

I'll be writing a small desktop app for a client that has WinXP machines and they won't be installing the .NET framework (at least not for me). So my choices are limited to either C++ or VB6, neither of which sound great. I remember reading back in the day that Mono came up with a static compiler, but recently the only thing I could f...

Unable to make static reference to generic subclass (Java)

Hi, I have the following code: class SuperClass { public static String getName() { return "super"; } } class SubClass extends SuperClass { public static String getName() { return "sub"; } } public class Dummy<T extends SuperClass> { public void print() { System.out.println("SuperClass: " + SuperClass.getName()); ...

Static Function Concurrency ASP.NET

If you have two threads invoking a static function at the same moment in time, is there a concurrency risk? And if that function uses a static member of the class, is there even a bigger problem? Are the two calls seperated from each other? (the function is like copied for the two threads?) Are they automatically queued? For instance...

Invoke static initializer

Once a class is loaded is there a way to invoke static initializers again? public class Foo { static { System.out.println("bar"); } } Edit: I need to invoke the static initializer because I didn't write the original class and the logic I need to invoke is implemented in the static initializer. ...

How to allocate array in base constructor with size based on derived class?

I have a hierarchy of classes. The base class uses some tuning parameters that are loadable from file (and reloadable during runtime). Each derived class may add some additional parameters. I am looking for a way to allocate a correctly sized parameters array in the base constructor, so that I don't have to deallocate and reallocate ...

How is the lifetime of a static class affected in a stateless asp.net application?

I've defined a helper class to keep track of a small dictionary of items. it stores this information as a static property, which is initialized in the static constructor. the list is very small and will never change so I chose this method over xml or a db lookup table... however what I would like to know is, will this static property re...

requiring the presence of static methods in C#

Given a group of objects that have a common set of properties and methods in support of given domain logic, is there a way of enforcing the presence of certain static methods on these objects? I have concluded that implementing an interface does not achieve this (methods are instance only) and that static methods can not be marked overr...

C++ template static pointer-to-member initialization

I have a template class which has a static pointer-to-member, like this: template<class T, T* T::*nextptr> class Queue { T* head; T* tail; static T* T::*pnext; }; My question is how to write the initializer of the static pointer-to-member. I tried the obvious case: template<class T, T* T::*nextptr> T* Queue<T, nextptr>::*...

using static keyword in C local scope to function

Is there any difference in these two? If so, what exactly is the difference? Assume they are in a C function that may be called multiple times. declare and assign in same statement static uint32_t value = x; // x varies and may be passed into function. declare in one statement and assign in next statment. static uint32_t value; v...

Static instance, desctructor never called

Please see code below. The destructors are never called. Anyone know why and how this can be rectified? public partial class Form1 : Form { private Goo goo; public Form1() { InitializeComponent(); goo = Goo.GetInstance(); } } public class Goo { private foo f = new foo(); private sta...

Many objects with global and local state

I'm looking for the best Design for the following situation. We have many objects form one class, for instance a picture frame. Now each of the picture frames can display 3 types of picture. 1) a face 2) a screenshot 3) empty Thats easy: public enum PictureMode { Face, Screen, None } public class PictureFrame { priva...

static class and singleton

Isn't a class with all static members/methods a kind of singleton design pattern? Is there any disadvantage in particular of having such classes? A detailed explanation would help. ...

What's the equivalent of C's "static" keyword in Java?

Dear all,, I want to know what could be the equivalent keyword in java which could perform same function as "Static keyword in C".. I want to do recursion in java, performing same function that a static keyword in C does... Please help.. ...

How to compile C# application with C++ static library?

Hello, I turned my C++ Dynamic link library into Static library just to acquire more knowledge. My question is how can I use the .obj file to compile both projects with C# express/MS visual studio? ...