dcsimg
Results 1 to 7 of 7

Thread: Need Help With a Simple C# Program!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    1

    Need Help With a Simple C# Program!

    Guys ..

    Im a newbie to C# and I need some guidance to rectify this confusion I'm facing.

    I Want to call a class into the Main method.. And im getting this error :s

    Code:
    using System;
    
    namespace AddMinusDivideMultiply
    {
        class Program
        {
            public static int i, j;
    
            public static void Main()
            {
    
                Console.Write("Please Enter The First Number  :");
                string temp = Console.ReadLine();
                i = Int32.Parse(temp);
    
                Console.Write("Please Enter The Second Number :");
                temp = Console.ReadLine();
                j = Int32.Parse(temp);
    
                Minuz.minus();  // Here its generating an Error - Error    1    The name 'Minuz' does not exist in the current context    
    
            
            }
        }
    
        class Terms
        {
            public static void Add()
            {
                int add;
                add = Program.i + Program.j;
                Console.WriteLine("The Addition Of The First and The Second Number is {0}", add);
            }
    
        class Minuz
        {
            public static void Minus()
            {
            int minus;
            minus = Program.i - Program.j;
            Console.WriteLine("The Subraction Of The First and The Second Number is {0}", minus);
            }
        }
        }
    }

  2. #2
    Lively Member
    Join Date
    Oct 2008
    Posts
    87

    Re: Need Help With a Simple C# Program!

    C# is case sensitive.

    Minuz.Minus();
    Last edited by mjcoco01; Feb 27th, 2010 at 09:28 AM.

  3. #3
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    Re: Need Help With a Simple C# Program!

    "The only thing that interferes with my learning is my education."

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,705

    Re: Need Help With a Simple C# Program!

    While the previous two suggestions are relevant, I don't think they apply to this issue specifically. That error message suggests that your app can't see any type named 'Minuz'. That suggests that you either haven't referenced the DLL that it's declared in or you haven't imported the namespace it's a member of. I can only see a single 'using' statement at the top of your code so the second probably applies, but you may not have added the required reference either. Id this class defined in some other DLL? Have you referenced that DLL in your project.

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Need Help With a Simple C# Program!

    The indentation is out, Minuz is only accessible from within Terms.
    W o t . S i g

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,705

    Re: Need Help With a Simple C# Program!

    B*gger! Missed the scroll bar on the CODE window and didn't realise that you'd declared Minuz yourself. Sorry for the misdirection.

  7. #7
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: Need Help With a Simple C# Program!

    Hey,

    Slightly late to the party on this one, but it hasn't been marked as resolved, this would work:

    Code:
    Minuz.Minus();
    If you had changed to class definition to the following:

    Code:
    public static class Minuz
    Were you able to get this resolved?

    If so, remember to mark your thread as resolved, helps keep the forums organized.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width