Click here to Skip to main content
15,886,799 members
Everything / Static

Static

static

Great Reads

by Michael Haephrati
A Static Library which can be used for all kinds of database related needs
by c_a_dunlop
Get 10 tips for revitalizing your existing static analysis implementation—no matter what static analysis tool you're using.
by ToughDev
How to build Wireshark 1.12.5 static binaries for CentOS 5
by ASP.NET Community
GridView UtilitiesThe GetColumnIndexByHeaderText method shown below finds the column index inside a GridView control by passing to it a GridView

Latest Articles

by ToughDev
How to build Wireshark 1.12.5 static binaries for CentOS 5
by Michael Haephrati
A Static Library which can be used for all kinds of database related needs
by DotNetLead.com
How to build and deploy Angular application using GitHub and Azure
by Christian Specht
Jekyll dynamic tree menu: show the whole menu at once

All Articles

Sort by Score

Static 

8 Jan 2022 by Michael Haephrati
A Static Library which can be used for all kinds of database related needs
10 Apr 2015 by Sergey Alexandrovich Kryukov
It looks like everything is correct. All you might have missing is correct naming of the constant. (Again, please review my previous answer to the question you referenced, in part of namespaces.)This is how you can use this constant in the most general case, independent from content. It...
30 Jul 2015 by stibee
Did you tried x:static?See http://stackoverflow.com/questions/32395/accessing-static-fields-in-xaml[^]
16 Feb 2017 by F-ES Sitecore
Using singletons it is easier to control when the class is initialised to use things like lazy-initialisation etc. Using static classes you're pretty much get what you're given, your class is initialised on creation. Also using sigleton your ultimate class is still an object rather than a...
6 Nov 2018 by CPallini
You should declare your variable extern in the header and define it in the source file (without the static keywork: static in source file provides internal linkage). See, for instance: Internal linkage with static keyword in C - Stack Overflow[^].
6 Nov 2018 by Richard MacCutchan
You should not be defining them in the header file if they are static, just in the .cpp file. If you are trying to create global variables then you should declare them extern in the header, and give them a value in one .cpp file only, like: // header.h extern int variable; extern int...
16 May 2011 by Keith Barrow
With respect to the "main" service class: Although can add static methods to the class but these can't be implementation(s) of web methods. The web service is defined by its Interface and C#/VB won't allow you to implement Interface methods with statics, so you'll get a compile error. For this...
16 May 2011 by Espen Harlinn
Apart from what Keith mentions, there are a few things you can take into consideration.Proper design for a particular purpose depends on leveraging your knowledge about the data model, and the operations that will be performed on the data. There is nothing that prevents multiple threads...
10 Jul 2011 by Manfred Rudolf Bihy
It's by design. Static methods have their merit in cases when functionality is independant to instance variables. Also it's important for program entry points like main in applications. Cheers!—MRB
22 Mar 2013 by Shrestha Santosh
Did you go through you academic book before you write down this question?there are different sources where you can find about the static class, function and values.Make sure you go through the book of Quote:E. Balagurusamy or go through this site to get this book and study in...
29 Apr 2013 by Leo Chapiro
Probably you have to have a declaration in your executable which uses DLL, like this:declspec( __dllimport ) extern int MyClass:: num;If it does not help, then add a static helper function for accessing that variable, for example:AFX_EXT_CLASS class CTest1{ static int...
7 May 2013 by c_a_dunlop
Get 10 tips for revitalizing your existing static analysis implementation—no matter what static analysis tool you're using.
1 Aug 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Use Session. Store DataTable in Session and retrieve and modify whenever you want.
4 Oct 2013 by BillW33
As SA said the definition of static members is allowed. I was able to compile your code and it runs without any errors from the compiler. You should have described to us exactly what error your are seeing, that greatly helps us to provide the answer that you need. BTW, I am using Visual Studio...
14 Nov 2014 by Sergey Alexandrovich Kryukov
Are you sure this is a valid answerable question? This is a wrong approach to understanding things.You don't need to look for benefits. Instead, you need to 1) understand what exactly one or another language and platform feature does; 2) analyze what do you need to achieve; 3) based on that...
16 Feb 2015 by OriginalGriff
As little as possible should be static - excepting extension methods, which have to be, and some methods which are "generic" to an application rather than specific to a class.C# is an OOPs language - and the first "O" is for "Object"! If you make everything static, then you are ignoring what...
25 Dec 2016 by Kornfeld Eliyahu Peter
Because you used static variable it will have the same value across all instances (which is probably very bad), so if you add elements form one instance those will be there when you are in an other instance...As told before this probably very bad and for sure not advised...However, if by any...
16 Feb 2017 by Maciej Los
Check past answers to the questions:Singleton Class Vs Sealed Class Vs Static Class[^]How can I decide that I should use Static class or singleton class ??[^]Difference between static class and singleton pattern? - Stack Overflow[^]
31 Mar 2010 by Deepak Goyal1
Hello,Does anybody know where I can get coding guidelines for ATL COM. I mean best coding practices or static analysis rules.Thanks!
31 Mar 2010 by Eugen Podsypalnikov
A possible beginning[^]... :)
5 Apr 2010 by geekox86
I tried to compile Qt+Webkit statically with MS VS 2008 and the following worked.C:\Qt\4.6.2 configure -release -static -opensource -fast -no-exceptions -no-accessibility -no-rtti -no-stl -no-opengl -no-openvg -no-incredibuild-xge -no-style-plastique -no-style-cleanlooks -no-style-motif...
19 May 2010 by Not Active
You'll need to pass a reference to the Serial class to the child form obviously. :rolleyes: Create a overloaded constructor and pass it in or create a property and set it.
9 Aug 2010 by Christian Graus
Godaddy is crap. Beyond that, don't post your email address on a public forum unless you want a bigger penis and a russian wife, and use the article forum to talk to an article author. it's at the bottom. This is quick questions, a general forum.
24 Aug 2010 by Sauro Viti
What you are talking about is something like this:void SomeFunction(void){ static int sVar = 1; ...}It is possible to do this in C and C++, but it is not possible in C#. Be aware that the C language is not object oriented and the C++ is a multi paradigm language.The C#...
27 May 2011 by Not Active
I think if you researched patterns like MVC or MVVM you would get a solution. Anything that required access or manipulation of a UI element should, of course, be in the form or dialog. Anything else can be moved to an external class so it can be used in any situation. Use databinding to...
10 Jan 2013 by Allgaeuer
Ok, i found the solution.See the following links:Visual Studio 2010 not autolinking static libraries from projects that are dependencies as it should be supposed to[^]What does the “Link Library Dependency” linker option actually do in Visual Studio 2010?[^]
29 Apr 2013 by pengm
static export error: in test1.dll: xxx.h class AFX_EXT_CLASS CTest1 { static int num; } xxx.cpp int CTest1::num = 0; in a cpp of test2.dll: test2 is dependent test1.dll ... int i = CTest1::num; ... in a cpp of...
3 Oct 2013 by Sergey Alexandrovich Kryukov
This is just the false statement. Of course they are allowed. Why not?!I never heard of C++ version which would not allow such members, it would be against everything. :-)[EDIT]Please read:...
2 Oct 2013 by pasztorpisti
C++ allows the initialization of static members inside the class declaration only in case of static const integral values.class CStaticTest{public: void Test() { printf("%s(%d)\n", __FUNCTION__, g_Member); }private: static const int64 g_Member =...
11 Dec 2014 by Sergey Alexandrovich Kryukov
Trying to make anything global is really a bad habit. Why?Static methods, though, are very useful, but only use them if they work only with the object passed as parameters, plus (optional) return object, nothing else; it will help you to avoid static variables, which are potentially...
6 Jan 2015 by Nathan Minier
A static field will always refer to the same memory location (in the same AppDomain), regardless of which instance of the class uses it. This will mean that all instances of TestClass have the same intEditor and strName. It doesn't matter what file the code sits in, at the end of the compilation...
30 Jul 2015 by Maciej Los
Not sure i understand you well (because of this: "the required direction is from the UI to the property; The other direction is not required, but doesn't make a difference"), but...I'd suggest to read this: Static Classes and Static Class Members (C# Programming Guide)[^] - Static Members...
10 Oct 2015 by Member 10772541
Hello Guys,I read below post and confused what is the best way for datacontext creation and consumption ?http://www.foliotek.com/devblog/avoid-static-variables-in-asp-net/[^]I always thought that we should use singleton like below(+locking) private static ModelDataContext...
25 Jan 2016 by Philippe Mori
One way to do it is to derive from an interface with only read-only members. And you change the type of the "constant" to be the type of that interface instead.interface IPointXY{ float X { get; } float Y { get; }}public class PointXY : Point2D, IPointXY { public static...
1 Aug 2016 by johannesnestler
No memory leak - wyh do you think that? - but no need to recreate the same list again and again on every property access. Just make a static List variable and initialize once (if null), then return the list.
19 Sep 2016 by Karthik_Mahalingam
Quote:Uncaught ReferenceError: getdata is not definedgetdata function is enclosed with jquery, remove it. $( function getdata(obj) { and remove ) at the end of the function.
15 Oct 2016 by Richard MacCutchan
Your constructor will print that value of parameter x Not instance value x. If you want the latter then you need to use the this Prefix to disambiguate it, thus:System.out.println(this.x);
28 May 2017 by OriginalGriff
They aren't! The main method must be static, because static methods do not need an instance of the class in order to be called - all non static methods require an instance of the class to be created before you can call them. Since the main method is where your application starts, you can't...
17 Jul 2017 by Jochen Arndt
It would be good to see the full error message to see which function(s) are missing. If you build your app without MFC support, it is not linked with the library that contains the CString support functions. Because you are including atlstr.h, you are not getting compilation errors. But in the...
10 Aug 2017 by BillWoodruff
The compiler is telling you that it has not completed compiling the Class, and the Method body you try to reference is not available. Create a Constructor for the Class and set the reference to the Method there: public partial class ScreenShotConfigurationForm : Form { private const int...
14 Aug 2018 by Richard MacCutchan
static_cast
17 Aug 2018 by OriginalGriff
No. For a method there is no significant performance difference - the code is loaded once only for all instances regardless of whether it is static or instance related. The individual instances do not get a separate copy of the method as it's code, which is read only anyway!
17 Aug 2018 by Jochen Arndt
There is no significant difference in memory usage and peformance between static and non static methods. The only difference is that non static methods have a hidden parameter to the class instance. This results in a few more bytes of code which execution took some time. But it is negligible. ...
28 May 2021 by k5054
The simple thing to do is to add a width specifier to your format string e.g scanf("%32s\n", name[i] However, if you enter a name with spaces in it e.g. "James Earl Jones", then using the %s format, scanf will read this as 3 separate words, not...
7 May 2023 by ToughDev
How to build Wireshark 1.12.5 static binaries for CentOS 5
2 Apr 2010 by Alain Rist
You will find lots of interesting and well written code in Bjarke Viksøe's site ATL section[^].cheers,AR
6 May 2010 by Nishant_Mishra
Good Morning,I have written a Web Method which is called by page method through Java script, this web method executes on button click and as it needed to be static i m not able to call the page controls thus i have another non static method to retrieve the value of radio-button. no as web...
19 May 2010 by diialer
Hi,i've got a main form. It's an MDI Parent. In this parent i'm opening a second form and and i'm using a class.Looks like this:public partial class Main : Form { Serial serialPort = new Serial();[...] Util childForm = new Util();[...] ...
20 May 2010 by diialer
Is it possible, that you give me an example, cuz i can't find any article. May i search with the wrong keywords. :doh:
9 Aug 2010 by Miladfa
Hi MohanThanks for providing a nice article.I am using your scripts for creating friendly url.Locall Machine is working fine.When I tried using this in two different shared hosting (Godaddy & 1And1)Its not working in both of the servers..GODADDY The page you tried to...
24 Aug 2010 by DavidKiryazi
Hi,C# does not support static variables within methods. To do what you are trying to acheive, you should use a member variable with class scope (ie outside the method).Dave
24 Aug 2010 by cppwxwidgets
it is impossible to have a static local variable in c# if you try to do so you will get the following errorError 1 The modifier 'static' is not valid for this item
24 Aug 2010 by cppwxwidgets
Hi alli wanted to ask if it is possible to have a kind of variable in c# that behave like static local variable in c++,I mean I want to have a local variable in a method, that it is assigned (initialize) just the first time the method invoked and after calling the method again and again it...
24 Aug 2010 by DaveyM69
If you don't want it to change after initialization declare it static readonly. If you want to be able to change it later but have it retain the value between instances just mark it static.
24 Aug 2010 by cppwxwidgets
I want it to be local and in local scope we are not allowed to use static keyword at all, isn't it?
30 Nov 2010 by ToniChen
Does static methods use up the application resources, which will not be released even if the instance of that class is released?And is there any potential risk to static methods if their class will be used in a multi-threading environment?In design wise, when should we use private static...
30 Nov 2010 by Hiren solanki
Let me try to make you clear about that.with static method It would have one and only instance you will access same instance when you call the static method, So it solves the problem of memory consumption.While with instance method method inside every object will have different values...
29 Apr 2011 by Sergey Alexandrovich Kryukov
The lock statement only makes sense if anything in your protected block is accessed by some other thread of the same process. If this is the case — the code is probably correct, if not — it is redundant at best.—SA
27 May 2011 by H.Johnson
Hi all,I have a MainForm, a DialogForm and a MyClass containing most of the methods I use. I have the situation below;I) on MainForm : I create an instance of MyClass in order to access methods or procedures on MyClass. There is no problem for this.II) on MyClass : For some methods...
27 May 2011 by Sergey Alexandrovich Kryukov
"Without creating an instance" simply means you need a static method with internal or public access. However, it's hardly an elegant way in case of main form class. If you don't need an instance of this class, why not having the method is some other class, let's sat, a utility class?—SA
27 May 2011 by Sergey Alexandrovich Kryukov
"Without creating an instance" simply means you need a static method with internal or public access. However, it's hardly an elegant way in case of main form class. If you don't need an instance of this class, why not having the method is some other class, let's say, a utility class?—SA
10 Jul 2011 by deepak_rai
Why static members are accessible outside without making instance?
10 Jul 2011 by Abhinav S
That is the whole idea behind static.Any static method can be accessible without using an instance.
10 Jul 2011 by Nagy Vilmos
Further to the other answers, static members belong to the class and not the instance. Because they are class related, there is no requirement for an instance to be created. Also, as they do not belong to any specific instance, you cannot reference the this pseudo-variable.
2 Sep 2011 by Im2N00By
Hello once again,I'm coding an static library and there is a one class. But I don't understand why all the member variables and methods (all variables are private) are visible in generated lib file. Even the paths and project command line can be found there. As-well there is a lot other...
2 Sep 2011 by enhzflep
How about the option /PDBSTRIPPED ? Any good for your purposes?MSDN - "/PDBSTRIPPED (Strip Private Symbols)"[^]
26 Dec 2011 by lilyNaz
Hi,I need an open source dissassembler(preferably in c++) which can determine API function calls(statically ofcourse) so that I can extract API call sequences from it. Has anybody worked with an open source dissassembler?I need to disassemble the exe, and binary files which can be...
26 Dec 2011 by Mehdi Gholam
Try these :http://en.wikibooks.org/wiki/X86_Disassembly/Disassemblers_and_Decompilers[^]http://boomerang.sourceforge.net/[^]
15 Feb 2012 by SHWRRMSH
I read this article on creating multiple splitter views on a Window using an MFC SDI Application. http://www.vckbase.com/english/code/doc_view/SdiMulti.shtml.htm How can I choose the split (For eg:- 1x2, 3x1 etc.,) from the menu bar and split the *current window* (not a new window) for an...
16 Feb 2012 by Richard MacCutchan
Pleas do not post the same question in multiple places; you already posted this here[^].
12 Mar 2012 by lukeer
Hi experts,I have a bunch of static member fields like shown below. Throughout the application, a FirstEntry should be unique.Now I want to log which one of those is pointed to by "testEntry".The ToString() method inherited from System.Object returns the class name. I need it to return...
12 Mar 2012 by Sunasara Imdadhusen
1. I have created Test Class which contain Static Class and Property.namespace QSys.Data.Domain.DataSecurity{ public static class TestData { public static string MyName { get; set; } }}2. Customer Model class and Custom Validationnamespace...
26 Jun 2012 by Vaibhav_J_Jaiswal
HiCan anybody tell me, that how to change the static control's caption dynamically on the click event of check box without using the click event message. My requirement is as follows:When user select the check box caption becomes shows "Weighted" and after deselect caption becomes...
26 Jun 2012 by Style-7
Check box will send the message WM_COMMAND. Use function IsDlgButtonChecked for check box and SetWindowText to static control.
10 Jan 2013 by H.Brydon
I'm not following the story quite 100% but it sounds to me that you have something mixed up in the __declspec(dllimport) and __declspec(dllexport) symbols. Make sure that you have these and the macro symbols using them set up correctly.
31 Jan 2013 by GigaKatowice
Hi.I need to create a GlobalConfig class. But I want to derive from it in another class.Here's an example:public class BaseConfig { public string GlobalPath {get; set;}}public class ConfigA : BaseConfig { public string pathA {get; set;}}public class ConfigB : ...
30 Jan 2013 by E.F. Nijboer
Change the private constructor to protected.Good luck!
12 Feb 2013 by shajarian_lover
Hello all, I want to initailize Return an 2D string array from ASP static WEbMethod to Javascript functionas a Return value but i can't do itfor example, in ASP Method:[WebMethod]public static string[,] Method(string id){string[,] str; // the number of rows and columns are...
25 Mar 2013 by Style-7
1) Static variable = global variable but visible only in target function or structure or class. So value of static variable is not delete.2) Static member of class or structure = global variable for all objects of the class. For example for count objects of the class.class MyClass{...
25 Mar 2013 by Richard MacCutchan
If you really want to learn about C++ then this is the place to start[^].
27 Mar 2013 by Grant Mc
Could someone please explain briefly how I create a static variable in a static classIn my code below I can create the Document and Element varaibales fine,So how do I create a varaible from a static class that I have created? public static class Settings { public...
27 Mar 2013 by Ian A Davidson
You can't create an instance of a static class. The whole reason it is static is because you don't need to do so, since all properties and methods are static.I suspect you want to make FileInfo non-static (and its properties as well).Regards,Ian.P.S. I would add that the System.IO...
28 Mar 2013 by José Amílcar Casimiro
static (C# Reference)[^]
29 Apr 2013 by JackDingler
The issue is likely that because you have a DLL importing symbols from another DLL, and that all of the symbols are being marked for export as du[DE] explained above.What you need are conditional declarations dependant on each DLL, so that they won't be mistakenly interpreted incorrectly by...
12 Jun 2013 by vijay kakani
Hi Everyone,I'm new to Open CV and present working on my project which needs background separation done with OpenCV.Two days back I configured Open CV with Visual Studio C++ 2010 and worked on small tutorials from this blog http://opencv-srf.blogspot.ie/By I am not sure about how to...
27 Jun 2013 by Jeneesh K. Velayudhan
I have one Initialize() in my class and I am calling a delegate wrapper method from this function as follows (the call back method will call around 20 times in a sec),public Initialize(){ CX_OUTPUT_CALLBACK cb = new CX_OUTPUT_CALLBACK(OutDelegateCb); ...
3 Oct 2013 by User 59241
I think your question is badly worded. It appears you wish to know the number of the class instance. You could achieve that by doing this:class foo{private: static int count; const int mycount;public: foo() : mycount(++count) { } const int getcount()...
11 Oct 2013 by ASP.NET Community
GridView UtilitiesThe GetColumnIndexByHeaderText method shown below finds the column index inside a GridView control by passing to it a GridView
11 Oct 2013 by ASP.NET Community
The Localize Control lets you localize any element on an .aspx page. It provides adesign time feature not offered by its base class, the Literal
11 Oct 2013 by ASP.NET Community
Since the dawn of asp.net, web based development has become a lot easier.  It provides a great deal of control over designs and code.  And affords
11 Oct 2013 by ASP.NET Community
Most of the time when i tried to search for executing server side static page methods using jquery I came across simple example which explained how
11 Oct 2013 by ASP.NET Community
Hi Friends,In this article I will show the magic of Json and with a plus, the Model Binder that we know that MVC3 have by default, This is a simple
11 Oct 2013 by ASP.NET Community
Factory method is "Define an interface for creating an object, but let the subclasses decide which class to instantiate." In simple words we
11 Oct 2013 by ASP.NET Community
How to Get MacAddress and Get All Adapter Types in ASP.NETIn this demo we will see how to get MacAddress in ASP.NET in easy steps. In the first
11 Oct 2013 by ASP.NET Community
I’ve been heads down for the last several weeks Scrumming and it has been a while since I’ve updated my blog so I figured if I was going to keep your
11 Oct 2013 by ASP.NET Community
Hello friends.I am going to share with you a concept to call server side method from client side using script manager.Step 1 : Put ScriptManager on
11 Oct 2013 by ASP.NET Community
In this article we are seen how to create a custom HTML Editor control to add image button in it.  Create A
24 Nov 2013 by brocrag
Hello,I'm in the conceptual stages of a project which is intended to be distributed to several platforms (Windows and Linux/Mac primarily). Through reading through the literature I have opted for an MVC architecture, with the model being a C++ library and the view/controller being coded...
24 Nov 2013 by Chao Sun
Well, As you have already considered, there is no way(at least now) to create a light weighted cross platform MVC lib. To some extent, M and C are possible. but View from my point of view, one need to write the abstraction layer to adapt to different platform.moreover, MVC is certainly not the...
25 Nov 2013 by Stefan_Lang
You might want to internet-search for platform independent GUI frameworks. QT (link to wikipedia)[^] is such a framework which may or may not conform to your requirements. Note that the concept of DLLs is not about portabilty at all, it's about scalability and managing resources! Moreover...