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);
}
}...
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
...
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...
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...
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 { ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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 ...
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...
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...
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)...
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
...
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(...