c# - Ambiguity error? -


so i'm rather newbie when comes programming in c# have error need with?

so i'm trying create rpg system started out before else battle system barely began code store in form1.cs such

    using system.drawing;     using system.linq;     using system.text;     using system.windows.forms;  namespace windowsformsapplication1 {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }         public class variables{         public graphics character;         private void form1_load(object sender, eventargs e){         }           }          private void form1_keydown(object sender, keyeventargs e)         {             switch (e.keycode)             {                 case keys.up:                     player.top = player.top - 5;                     battle.steps = battle.steps + 10;                     break;                 case keys.down:                     player.top = player.top + 5;                     battle.steps = battle.steps + 10;                     break;                 case keys.left:                     player.left = player.left - 5;                     battle.steps = battle.steps + 10;                     break;                 case keys.right:                     player.left = player.left + 5;                     battle.steps = battle.steps + 10;                     break;             }             if (battle.steps == 100)             {                 battle.fight = true;             }         }     } } 

and battle.cs

    using system; using system.collections.generic; using system.linq; using system.text; namespace windowsformsapplication1 {     public class battle     {       public static bool fight {get; set;}        public static int steps;         public void fight (){       if (fight == true)     {      }        }     } } 

however i'm getting error error ambiguity between 'windowsformsapplication1.battle.fight' , 'windowsformsapplication1.battle.fight()' when try access variable in form 1 , when try edit in in battle.cs what's going on how fix or there better way this?

the best can figure without seeing battle class have variable named fight , method fight such as.

public class form {     {         battle battle = new battle();         battle.fight = true;         battle.fight();      } }  public class battle {     public bool fight = false;     public bool fight()     {         return true;     } } 

this cause ambiguity if call fight have hard time figuring out whether calling variable or method. fix maybe give variable or function different name. such if variable fight bool see if in fight or should fight maybe name variable infight or shouldfight.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -