Where is C# Windows Form Application main() function -


in c# windows form application,

  • i have class race.
  • i want declare object of race class
  • and access object when button clicked

.

race class:

class race {     int player;     int position; } 

object creation:

race obj = new race(); 

accessing object:

    private void button1_click(object sender, eventargs e)     {         obj.position++;     } 

the question is, create race class object, can access when button clicked?

you'll need declare @ class level. in case, means needs field in form:

public class form1 : form {     private race race;      public form1()     {         race = new race();     }      public void button1_click(object sender, eventargs e)     {         race.position++;     } } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -