In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent
For example:
#include <stdio.h>
void foo_bar( void )
{
static counter = 0;
printf("counter is %d\n", counter);
counter++;
}
int main( void )
{...
We actually have burned static/archived copies of our asp.net websites for customers many times. We have used WebZip until now but we have had endless problems with crashes, downloaded pages not being re-linked correctly, etc.
We basically need an application that crawls and downloads static copies of everything on our asp.net website ...
Let's say I have a class designed to be instantiated. I have several private "helper" methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result.
public class Example {
private Something member;
public double compute() {
double total = 0;
...
Is it possible to print the class name from within a static function?
e.g ...
public class foo
{
static void printName()
{
// Print the class name e.g. foo
}
}
...
Pretty horrendous newbie question here.
I'm looking at the following apple example source code:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFor...
Can I call HttpContext.Current from within a static class and Method?
I want to store a value on a per-user basis but want to be able to access it in a static manner.
e.g. Will this work?
public static class StatClass
{
public static string SomeThing
{
get { return HttpContext.Current.Items["SomeItem"].ToString(); }
...
Hi all,
I have a case in which I have to read an input file in the C'tor, but sometimes this file doesn't exist.
This object is usually held statically, so its C'tor is called while loading the dll.
I can't catch the exception I throw if the file doesn't exist because it's too early, and my executable crashes in an ugly way.
I know it's...
Ok, I understand what is static variable is, but what is a "static" function?
And why is it that if I declare function let's say "void print_matrix" in let's say a.cpp (WITHOUT a.hpp) and include "a.cpp" - I get "print_matrix@@....) already defined in a.obj", BUT if I declare it "static void print_matrix" then it compiles?
UPDATE Just...
The application I'm working on has a single class that maintains a database connection. All members of this class are static to enforce a singleton-like pattern, so the actual connection logic is performed in a static initializer block:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
...
I am considering using a Shared (read static) WCF proxy client for a high throughput application. I believe there is a performance gain in doing this, but I have not benchmarked this as yet.
Are there some serious pitfalls to this idea?
From my research I can see that there is the issue of handling the fault state, it is not clear wh...
I am converting about 4000 text files that contain HTML into MySQL database entries. Seems like an easy way to do this would be to add a couple lines to the HTML to make them appear as XML files, then XSLT the XML into MySQL INSERT statements. (Building a CSV would also work, but less optimal IMHO). I've tried doing this but am having li...
I've seen the word static used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)?
...
I have an ASP.NET application with a lot of dynamic content. The content is the same for all users belonging to a particular client. To reduce the number of database hits required per request, I decided to cache client-level data. I created a static class ("ClientCache") to hold the data.
The most-often used method of the class is by ...
There are a lot of discussions all over the internet and on SO, i.e. here and here, about static vs dynamic languages.
I'm not going to ask again about one vs another. Instead, my question is for those who moved (or at least tried to move) from static typed language to dynamic.
I'm not talking about moderate usage of JS on your web pag...
As a Swing developer for as many years as one can possibly be a Swing developer, I've identified a lot of patterns that I use in laying out components. For example, I often create components that are associated with a JLabel. I usually write:
JPanel panel = new JPanel(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.ad...
I have a class, lets call it A, and within that class definition I have the following:
static QPainterPath *path;
Which is to say, I'm declaring a static (class-wide) pointer to a path object; all instances of this class will now have the same shared data member. I would like to be able to build upon this class, subclassing it into mo...
I have form with button and checkbox. if i hit button static void is called which call non static void which shows messagebox with the checkbox.checked.toString()
The problem is if i change the checkbox value it always shows false
Code is
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
...
I have a static web site that need to display a video. I do not control the server (but know the guy who does). Is there any "host some files and add some boilerplate" ways to display the video as part of the page? I'm thinking of something that would look like an embedded youtube video.
I'd rather keep stuff local (I don't have a youtu...
Is it OK to have a static member variable defined in a base class, and having several derived classes each using its own instance of this member variable?
The following code compiles successfully, and prints the right output, but I am still not sure that doing something like that is a good practice. In the following example, how can it ...
I am looking to provide some convenience through reflection to programmers who will be using my code. To achieve my desired result I would like to get the class object for classes that extend my code. Even though they can't override the static method I wish to access the information from, it would be currently helpful. I may end up si...