|
I have written an ASP.NET HttpModule and I have a static helper class that is used to load and store configuration data for the life of the request.
Since static constructors must be parameterless, I have a static SetConfigName method that I call at the...
Started by ObiWanKenobi on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If....
The only way to get around data.
Multiple requests do share the same static data.
To store static data for 1 request, you should use HttpContext.Current.Items.
Static data is shared between requests.
|
|
From MSDN document i understand ( I am not sure,i understand perfectly ) :
Static members can operate only on static data and call static methods of the
defining class.
I worked out the following code :
class Test { static int i; public static void StaticDemo...
Answer Snippets (Read the full thread at stackoverflow):
In other....
If v the static method.
It works because v is local to the static function itself.
Of course, every method can declare local variables and use them .
Instance members within a static method if you don't pass in an instance.
|
|
I want to ship static read-only data for use in my Core Data model. The problem is that there are obviously different persistent store types and I don't know if the format of those types is supposed to be opaque or if I'm supposed to be able to construct...
Started by Nimrod on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I plan to write a small mac utility (using the same data model) to generate the Core ....
Core Data SQLite file to ship with your app.
With some static read-only data in a plist file! (TemperatureData.plist) So go figure....
|
Ask your Facebook Friends
|
In VB.Net, I can declare a variable in a function as Static, like this:
Function EncodeForXml(ByVal data As String) As String Static badAmpersand As Regex = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)") data = badAmpersand.Replace(data, "&") ''// ...
Started by Joel Coehoorn on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You....
As a side note: I'd expect to see that logical model clearer, IMO .
By the CLR, and the VB compiler creates a static (shared) variable "under the hood" in the method's class to make sure the static member is thread-safe as well.
|
|
If one static data member depends on another static data member, does C#/.NET guarantee the depended static member is initialized before the dependent member?
For example, we have one class like below
class Foo { public static string a = "abc"; public...
Started by Morgan Cheng on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Take this, for example:
class....
Like said before, static field initialization is deterministic and goes according to the textual declaration ordering.
All static members will be initialized upon loading of the classtype holding them.
Before.
|
|
I have a C++ class which contains only static data members. I noticed the compiler is OK if I define the access methods as const, as static, or as "regular" - so all seem to work.
My question is what is the correct/better practice in this case?
Thanks...
Started by Mym on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Then that probably probably ....
I have a C++ class which contains only static data members.
If your class contains only static members, you should the namespace syntax.
Static accessors for static data members.
|
|
The background to this question is that I need to use some user session data in a (static) WebMethod. I have created a static property that references the data I need like so:
private static UserWebSession UserWebSession { get { return (UserWebSession...
Started by MalcomTucker on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
It's dependent on the thread though (I believe) - so if you start any extra background threads, they won't be able to see the current... .
You won't get a previous user's session.
That's fine - HttpContext.Current is designed precisely for this sort of thing .
|
|
Hello,
I have a class with a complex data member that I want to keep "static". I want to initialize it once, using a function. How Pythonic is something like this:
def generate_data(): ... do some analysis and return complex object e.g. list ... class...
Started by Rax Olgud on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Here's an example that demonstrates....
data_member will be created once, and will be available to all.
( SeeYou're right on all counts.
You're right.
The "static" data_member can still be accessed by typing coo.data_member .
To that instance.
|
|
I have a few questions about the static keyword in C++ (and probably with other languages as well.) What is the purpose of declaring a function as static?
void static foo(int aNumber) { ... }
How about a static inline function?
void static inline foo(...
Started by Dooms101 on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Depends on Context:
Like many things in C++, static means different things depending on its context of static:
If you declare a function or variable as static outside of a class and in global scope a forward declaration) you will ....
|
|
I have some status data that I want to cache from a database. Any of several threads may modify the status data. After the data is modified it will be written to the database. The database writes will always be done in series by the underlying database...
Started by danio on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
WriteToDB(); } private: static void WriteToDB(); // read data under mMutex.lock()! static Mutex mMutex there is some amount of automatic synchronization of static data and static methods with it with bools....
|