Linked Questions

-5 votes
1 answer
1k views

I created a static variable in a class and incrementing in the constructor, thinking that whenever I created an instance to the class, the static variable will be reset to 0. To my surprise, the first ...
Sunilkumar Mandati's user avatar
-7 votes
1 answer
1k views

Does anybody know how to modify a static variable from a different script in Unity?
DubGamer87's user avatar
0 votes
1 answer
519 views

I am new to C# and I came across the following query. Since a class is not an object but just a blueprint(template), how is it possible to define static members on the class and access them by using ...
Unknown developer's user avatar
-4 votes
1 answer
548 views

I'm wondering I can't reach static class field from instance variable class aa { public static string b = "bb"; } Console.WriteLine(aa.b); //fine aa f = new aa(); f.b ...
vico's user avatar
  • 18.5k
3 votes
4 answers
45k views

I am new at programming and I am trying in vain to create a function that returns an auto increment id, however the code isn't working and I'm sure there's something missing even though I don't get ...
Ricardo's user avatar
  • 87
5 votes
5 answers
3k views

I've been working in C for the past couple of years and I've managed to get use to putting single-purpose, static variables near where they are used within my code. While writing a very basic method ...
RLH's user avatar
  • 15.8k
6 votes
4 answers
2k views

I have to ask this question because I feel that only experienced programmers can know the pros and cos of static members in a class. I've read books explaining about static members, I've also used ...
King King's user avatar
  • 63.5k
4 votes
1 answer
6k views

I came to know that, From MSDN: C# does not support static local variables (variables that are declared in method scope). And here: The static modifier can be used with classes, fields, methods,...
Noor A Shuvo's user avatar
  • 2,885
2 votes
4 answers
525 views

Update for future readers: If you find this text too long: This is a race condition due to a static variable. What you are reading below is showing how confusing this can become for someone who is ...
Leif's user avatar
  • 2,170
1 vote
1 answer
3k views

Running the bellow code you can see that there is a different between CallContext and AsyncLocal. using System; using System.Runtime.Remoting.Messaging; using System.Threading; namespace ...
Fitzchak Yitzchaki's user avatar
1 vote
3 answers
2k views

i was writing code in MVC and i don't' understand behaviours public properties in my project!! my code its very simple, increment property. When i clik on button the property is overwrites. Its work ...
rejentt's user avatar
  • 81
0 votes
3 answers
2k views

I have four game objects with the same script and the same bool, when one of them get hit by ray the bool state is true, but the function will not start because the other three game objects is set to ...
Botros's user avatar
  • 3
0 votes
5 answers
684 views

Im gonna paste the code first so you can see what Im talking about: namespace Radni_sati { public class Blagdani { public List<Blagdani> Blagdani_lista = new List<Blagdani>(); ...
Marko Petričević's user avatar
1 vote
1 answer
708 views

I am new to C# programming and I am currently using many static variables in my code. Below is one example: class Program { public int I//Can be used to access the variable i anywhere from the ...
JOW's user avatar
  • 244
0 votes
4 answers
257 views

I've tried searching this but I cant find a clear answer to my question. When can you actually alter a static variable? From my understanding you can only change it within the static constructor. ...
Dan Beaulieu's user avatar

15 30 50 per page