static

Converting static link library to dynamic dll

I have .lib file with its header (.h) file. This file have a few functions that need to be used in C# application. After googling i found that i need to create a dynamic dll from this static library and call this dynamic dll from C# code using interop. I have created a win32 project and selected type dll. Included header file and adde...

Static method to be accessed by multiple threads, Java

Hi, I am using a third party library to do hand evaluation of 7 card poker hands. The method evaluate in this library is declared as public static and I believe it alters some global static arrays within the class. The problem I have is that as I am doing an enumeration algorithm of about 10m enumerations I want to parallelize it, there...

How do I enumerate a static dictionary contained in a static class from asp.net ( aspx) page

I don't understand how to loop over a static dictionary contained in a static class from my aspx page. I have this for the static class public static class ErrorCode { public static IDictionary<int, string> ErrorCodeDic; static ErrorCode() { ErrorCodeDic = new Dictionary<int, string>() { {1, ...

Static method in java

I heard that static methods should use only static variables in java. But, main method is also static, right? ...

Access a thread to notify it from another method (Android application)

Hi everybody, I'm developping an android application and trying to deal with threads without really knowing a lot about them... (Yeah bit stupid of me, I know) I'll try to explain it properly and quite quickly. In the onCreate method of my activity, I'm calling an AlertDialog to make the user choose to either load data from the internet...

Does C# support the use of static local variables?

Related: How do I create a static local variable in Java? Pardon if this is a duplicate; I was pretty sure this would have been asked previously, and I looked but didn't find a dupe. Is it possible for me to create a static local variable in C#? If so, how? I have a static private method that is used rarely. the static metho...

Objective-C protocol static method?

I have a protocol in objective-c, something like this: @protocol Handler +(NSString*) getValue; @end So now say I have an instance that inherits this protocol and I want to call this method: [handlerInstance getValue]; This give a warning because the getValue method is not an instance method. How can I properly call this method fro...

How do I reference a static method of a variable class in PHP?

Hi folks! I'm writing a factory class that should be able to return singleton instances of a number of different types, depending on the given parameter. The method would look something like this, but the way I'm referencing the singleton's static method is obviously wrong: public function getService($singletonClassName) { return $...

Memory allocation in case of static variables

I am always confused about static variables, and the way memory allocation happens for them. For example: int a = 1; const int b = 2; static const int c = 3; int foo(int &arg){ arg++; return arg; } How is the memory allocated for a,b and c? What is the difference (in terms of memory) if I call foo(a), foo(b) and foo(c)? ...

Call to method of static java.text.DateFormat not advisable?

I am receiving a Find Bugs error - call to method of static java.text.DateFormat and I don't know the reason why it's not good / advisable to be doing these things below. private static final Date TODAY = Calendar.getInstance().getTime(); private static final DateFormat yymmdd = new SimpleDateFormat("yyMMdd"); private String fileName...

A Simple State Machine using a Static class in C# to notify other subscribers via Events

I've been trying to write a simple Static-class State Machine for my application to notify other controls and code when the system state changes. And I think I almost have it, but I'm running into a small issue that I'm not sure how to work around. Here's the code: // An enum denoting the 3 States public enum Status { Error = -1, Work...

Are final static variables thread safe in Java?

I've read around quite a bit but haven't found a definitive answer. I have a class that looks like this: public class Foo() { private static final HashMap<String, HashMap> sharedData; private final HashMap myRefOfInnerHashMap; static { // time-consuming initialization of sharedData f...

C#: how do you refer to content in Program.cs in a form.cs?

I am trying to place a value (from an object) in a variable and place it in a textbox in a form. Here is the form code: public Form1(Deck mainDeck) { InitializeComponent(); int Val = mainDeck.ReturnCard(10); textBox1.Text = Val.ToString(); } mainDeck is an object in my Program.cs file The problem line...

How should I declare a constant set visible for every instance of the class?

I would like to have a constant set in my class which would be visible for all instances of the class. First, I do not know if I need to declare it as "static". As far as I understand any changes of a static field (done by one of the instances) will be seen by other instances (so static variable is not bound to a specific instance). Mor...

static class inheritant not work in PHP?

abstract class base { abstract public function test(); public function run() { self::test(); } } class son extends base { public function test() { echo 1; } } son::run(); It reports: Fatal error: Cannot call abstract method base::test() But son::test() works,why and is there a way to...

How to genericize a Java enum with static members?

Hi, I am refactoring a part of our legacy app which handles exporting and importing of DB tables from/to Excel sheets. We have a Formatter subclass for each table, to provide the definition of that table: how many columns it has, and what is the name, format and validator of each column. The getters which supply this data are then called...

Static Initialization Blocks.

As far as I understood the "static initialization block" is used to set values of static field if it cannot be done in one line. But I do not understand why we need a special block for that. For example we declare a field as static (without a value assignment). And then write several lines of the code which generate and assign a value to...

Volatile Vs Static in java

Is it like, static means one copy of the value for all objects , volatile means one copy of the value for all thread.? any way static variable value also going to be one value for all threads, then why should we go for volatile. Please help. I have confusion on this. ...

Symbian c++ - how to put own static lib

Hello guys. I'm using carbide c++. What to put in .mmp file to link some static library in path: camerawrapper\epoc32\release\armv5\lib from root? ...

WCF Static Variable Getting Reset with Each Call

I have a WCF service that I am calling from multiple clients. I need to store and manage a value globally. On my service I have the following attributes: [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)] In my service I have something similar to this: private static int coun...