-1

I have a class (mydatarec) in my project (client) that is referenced to another project (server). When I call the public double (xxr) in the other project (server) I always get a zero value:

///client///
public class mydatarec
{
   public static double xxr;
}
.
.
static void Main(string[] args)
{
   mydatarec.xxr = 100;
          ...
}

In the other project:

///server///
//When I call it here..
Console.WriteLine(mydatarec.xxr); // I always get 0

I dont know how to continuously change the static double. I need your help!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

You seem to assume that the value is shared by multiple processes. It's not. The static fields are shared only within one process (or more precisely within an appdomain).

If you actually need to share a memory between processes follow to question Shared memory between 2 processes (applications).

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • how come when i do public static double xxr = 1; I get a value of 1 (not zero) in the other project. I think xxr is already shared but im gettnig the initial value only. – Ahmad Manasrah Apr 15 '13 at 18:39
  • Because that new initial value is then set in both projects. So both start with 1. But that still does not make the value shared. – Martin Prikryl Apr 15 '13 at 20:00