Click here to Skip to main content
15,911,848 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sending files with data not compatable with a byte variable Pin
zaXch18-Mar-05 14:26
zaXch18-Mar-05 14:26 
GeneralRe: Sending files with data not compatable with a byte variable Pin
zaXch19-Mar-05 5:54
zaXch19-Mar-05 5:54 
Generalhelp with implementation Pin
John L. DeVito18-Mar-05 10:33
professionalJohn L. DeVito18-Mar-05 10:33 
GeneralRe: help with implementation Pin
turbochimp18-Mar-05 12:59
turbochimp18-Mar-05 12:59 
Questionhow to customize a window Pin
Pikebu18-Mar-05 8:52
Pikebu18-Mar-05 8:52 
AnswerRe: how to customize a window Pin
Judah Gabriel Himango18-Mar-05 9:40
sponsorJudah Gabriel Himango18-Mar-05 9:40 
AnswerRe: how to customize a window Pin
MoustafaS18-Mar-05 12:26
MoustafaS18-Mar-05 12:26 
GeneralStatic Values Pin
MrEyes18-Mar-05 7:20
MrEyes18-Mar-05 7:20 
Hello all

I was under the impression that if I make a call into a static function which uses the value of a static class variable, if I recall the function later the value of the static class variable would reset back to the default coded value.

Now as the following example prooves I am obviously wrong.

I have a test application/dll that has the following code :

StaticLib.dll
using System;

namespace StaticLib
{
 public class MyStaticLib
 {
  private static int val = 0;
  public static int GetNumber()
  {
   return val++;
  }
 }
}


Console Application (which references StaticLib.dll)
using System;
using StaticLib;
using System.Threading;

namespace StaticTest
{
 class Class1
 {
  [STAThread]
  static void Main(string[] args)
  {
   while(true)
   {
    Console.WriteLine(MyStaticLib.GetNumber());
    Thread.Sleep(1000);
   }
  }
 }
}


When I ran this for the first time I expected to get the following output

0
0
0
0
0
0


But I actually get

1
2
3
4
5
6
7


Could anybody explain why this is?

post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
GeneralRe: Static Values Pin
Colin Angus Mackay18-Mar-05 7:27
Colin Angus Mackay18-Mar-05 7:27 
GeneralRe: Static Values Pin
Ravindra Sadaphule18-Mar-05 11:43
Ravindra Sadaphule18-Mar-05 11:43 
Generalmouse drag over problem Pin
ppp00118-Mar-05 5:11
ppp00118-Mar-05 5:11 
GeneralRe: mouse drag over problem Pin
Judah Gabriel Himango18-Mar-05 7:22
sponsorJudah Gabriel Himango18-Mar-05 7:22 
GeneralMemory optimisation Pin
PaleyX18-Mar-05 5:10
PaleyX18-Mar-05 5:10 
GeneralRe: Memory optimisation Pin
Andy Brummer18-Mar-05 5:46
sitebuilderAndy Brummer18-Mar-05 5:46 
GeneralRe: Memory optimisation Pin
ACorbs19-Mar-05 11:40
ACorbs19-Mar-05 11:40 
GeneralGacUtil and RegAsm Pin
ppp00118-Mar-05 4:57
ppp00118-Mar-05 4:57 
GeneralRe: GacUtil and RegAsm Pin
Judah Gabriel Himango18-Mar-05 5:28
sponsorJudah Gabriel Himango18-Mar-05 5:28 
GeneralRe: GacUtil and RegAsm Pin
Mike Dimmick18-Mar-05 8:57
Mike Dimmick18-Mar-05 8:57 
GeneralMac address Pin
Member 178719018-Mar-05 3:54
Member 178719018-Mar-05 3:54 
GeneralRe: Mac address Pin
felopater18-Mar-05 15:13
felopater18-Mar-05 15:13 
GeneralRe: Mac address Pin
afinnell20-Mar-05 17:02
afinnell20-Mar-05 17:02 
GeneralPolicy not being applied to reference at this time Pin
Guillermo Jimenez18-Mar-05 3:47
Guillermo Jimenez18-Mar-05 3:47 
GeneralRe: Policy not being applied to reference at this time Pin
Member 9878981-Jul-10 12:26
Member 9878981-Jul-10 12:26 
Generaldraw on transparent control over a mediaplayer Pin
spAAwn18-Mar-05 2:57
spAAwn18-Mar-05 2:57 
GeneralRe: draw on transparent control over a mediaplayer Pin
MoustafaS18-Mar-05 12:35
MoustafaS18-Mar-05 12:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.