static

Sharing Static Data Outside of the Class

Hello. First, here is a motivating example: public class Algorithm { public static void compute(Data data) { List<Task> tasks = new LinkedList<Task>(); Client client = new Client(); int totalTasks = 10; for(int i = 0; i < totalTasks; i++) tasks.add(new Task(data)); client.submit(tasks); } }...

C# When to use Static Classes as opposed to Instances of Classes?

Possible Duplicate: When to Use Static Classes in C# Questions in the title..........i would greatly appreciate opinions on when it's best to use each? Regards ...

Static inner classes in scala

What is the analog in Scala of doing this in Java: public class Outer { private Inner inner; public static class Inner { } public Inner getInner() { return inner; } } I specifically want my inner class to not have to have a fully qualified name - i.e. I want Trade.Type, not TradeType. So in Scala I imagined it might be somet...

Objective C - static variables

I don't quite understand static variables when defined in the implementation of an interface. In methods I do understand how they differ from local variables, but not when defined directly in an implementation. Look at these examples. What difference do these two make practically? #include "MyClass.h" @implementation MyClass int myInt...

Question about non-static members of a singleton (C#)...

Hey folks, I have a question about singletons that I think I know the answer to...but every time the scenario pops-up I kinda second guess myself a little so I would like to know the concrete answer. Say I have two classes setup as so... public class ClassA { private static ClassA _classA; public static ClassA Instance { ...

How do you use the IS operator with a Type on the left side?

I have a method I'm writing that uses reflection to list a class's static properties, but I'm only interested in those that are of a particular type (in my case, the property must be of a type derived from DataTable). What I would like is something like the if() statement in the following (which presently always returns true): PropertyI...

Are static methods thread safe

I have a static timer class which will be called by ANY webpage to calculate how long each page has taken to be constructed. My question is are Static classes thread safe? In my example will concurrent users cause a problem with my start and stop times? e.g a different threads overwriting my start and stop values. public static clas...

How to declare static variables in Delphi 2009?

Hello, I googled,I binged,I already have seen the other "duplicates" here,but none of them work in Delphi 2009 updated up to update 4. Like in C#,I want to make a static variable in on line or as short as possible.In the end it works like a global variable,but its sorted. What's the shortest way to do this in delphi 2009? EDIT I fol...

I need to collect an array of classes to call their static variables in php

First thing i want to say that it's not an easy question to explain, so please be patient if it seems confusing. I have a set of classes like this class Product { public static $static_type = 'product'; public static $static_table = 'product_table'; public function __construct($params) { //do some } } and then there are t...

Local static variables in Timer.Tick event (Stopping a Timer)

I have a timer on a page in ASP.NET. After a certain period of time elapses, I want to disable the timer. I want to put a static variable in the timers tick event that will track how many seconds have elapsed. My question is, will this work? If user X and Y are viewing the page will they both have separate local static variables? Wh...

Declaring a const double[] in C# ?

Hello! I have several constants that I use, and my plan was to put them in a const array of doubles, however the compiler won't let me. I have tried declaring it this way: const double[] arr = {1, 2, 3, 4, 5, 6, 73, 8, 9 }; Then I settled on declaring it as static readonly: static readonly double[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9...

Do typedefs of templates preserve static initialization order?

Within the same compilation unit, the C++ standard says that static initialization order is well defined -- it's the order of the declarations of the static objects. But using the Sun Studio 12 compiler I'm encountering unintuitive behavior. I've define a templated class helper<T> which contains a static member _data of type T and a stat...

How do you Require Login for Media Files in Django

I'm serving "sensitive" information in downloadable PDF's and Spreadsheets within a user registration section of a site. Is there a way to allow the django authentication to secure this media without serving it (and not have to manually login using basic auth)? I'm guessing theres (fingers crossed) not a way to do it with the psuedo co...

Static classes with iPhone

I was just wondering if this is possible... if I have a "Static class" (a class with a bunch of static methods) is it possible to have a class variable and access it through one of the static methods? I am getting a warning of "instance variable accessed in class method". I maybe just not getting it. Is there anyone that can answer this...

TApplicationEvents as dynamic component or static for tracing called routine in Delphi.

Hello and good morning! Unfortunately I am not writing this question from my Developing PC so I might do some mistakes. Please sorry about it... So - my question - what approach you use to implement error logging in your application? In web ( http://delphi.about.com ) is nice event handler, but it just copies system error in file, but ...

Using SoftReference for static data to prevent memory shortage in Java

I have a class with a static member like this: class C { static Map m=new HashMap(); { ... initialize the map with some values ... } } AFAIK, this would consume memory practically to the end of the program. I was wondering, if I could solve it with soft references, like this: class C { static volatile SoftReference<Map> m...

Modifying a non-static object from a static method.

Hi, I'll first tell you what I am trying to do, and then how I am trying to do it. If there is a better way please let me know. I am working with two forms - lets call them form_main and form_preferences When the form_preferences form is up, I want form_main to be disabled until a button (save button) on the form_preferences is clicke...

Static counter to be repeatedly incremented by NSTimer

Every 1/16 of a second, I have an NSTimer that fires, calling a method each time. I want to create a static integer that is increased by '1' each time the method is called, once the static integer is equal to '16', I wish to call another method and reset the static integer to '0'. Any insight is greatly appreciated. (Language is Obj-C)...

Getting List of Static Libraries used in an executable

Since ldd lists only the dynamic libraries. Is there a way to extract the info. about static libraries used to create the executable ? TIA, Saurabh ...

C# -- how does one access a class' static member, given an instance of that class ?

In C#, suppose you have an object (say, myObject) that is an instance of class MyClass. Using myObject only, how would you access a static member of MyClass? class MyClass { public static int i = 123 ; } class MainClass { public static void Main() { MyClass myObject = new MyClass() ; myObject.GetType(...