Help please... instance reference; qualify it with a type name instead

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alireza6485
    New Member
    • Jan 2009
    • 19

    Help please... instance reference; qualify it with a type name instead

    Hi:
    I have 3 class/Methods:
    the first one:just beeps
    the second one:ask the user to Enter the number of beep
    The last one:Activate and runs.
    I get the following Error:"instance reference; qualify it with a type name instead "
    Can you please re-write the code and fix it for me,Thanks.

    First One:
    [code=c#]
    using System;
    public class AmbulanceSiren
    {

    public void Siren(int pattern)
    {
    for (int i=0;i< pattern; i++)
    {
    Console.Beep();
    Console.Write(" ");
    }
    }
    }
    [/code]

    Second One:
    [code=c#]
    using System;
    public class User
    {

    public static void Enter()
    {
    Console.WriteLi ne("Enter The Pattern:");
    AmbulanceSiren Test = new AmbulanceSiren( );
    int repeat = Convert.ToInt32 (Console.ReadLi ne());
    Test.Siren(repe at);

    }
    }
    [/code]

    Last One:
    [code=c#]
    using System;
    public class Driver
    {

    public static void Main(string[] args)
    {
    User Active = new User();

    Active.Enter();
    }
    }
    [/code]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Sounds like a homework assignment

    Can you please re-write the code and fix it for me,Thanks.
    Asking someone else to do your homework (or thinking) (or debugging) for you doesn't teach you anything.

    You didn't even mention where the error occurred. Visual Studio should have given you a line number for it.

    Comment

    • vekipeki
      Recognized Expert New Member
      • Nov 2007
      • 229

      #3
      Well, it looks like Active.Enter(); will throw that error, because Enter() is a static method, while Active is an instance of User class. There is also no reason why you couldn't make AmbulanceSiren. Siren() static.

      You should consider giving your classes names that are meaningful, because Active.Enter(); doesn't really tell you anything about what that method does, or what functionality is enclosed in that class.

      Comment

      Working...