• 0

[C#] "class name is not valid at this point" error


Question

Hey guys,

I'm trying to call a method with 1 argument. However, no matter where I call the method, I get an error saying "class name is not valid at this point."(and in certain places, I also get an error saying "redundant empty statement") The argument I'm calling is a class variable.

Here is my code so it makes a bit more sense with what I'm trying to say

PrintReceipt(Pump aPump);	//Method I'm trying to call

		public static void PrintReceipt(Pump aPump)	//The actual method
		{
			const double amountDispensed = 0;
			DateTime currTime = DateTime.Now;

			Console.WriteLine("\nAUTOMATED FUEL DELIVERY SYSTEM");
			Console.WriteLine("\nRECEIPT");
			Console.WriteLine("\nDate : {0:d}", currTime);
			Console.Write("\nPaid for {1:#.##} litres of ", aPump.getPrice(), amountDispensed);
		}

If anyone can help me out, that'd be great.

Thanks in advance,

Britt.

6 answers to this question

Recommended Posts

  • 0
  Pc_Madness said:
I think I see her problem,

PrintReceipt(Pump aPump);

Is that how your calling the function? You don't need to include the data type (aka Pump) when calling functions.

PrintReceipt(aPump);

should do the job. :)

Thanks for the reply guys!

Pc_Madness, I've tried that, and it throws an error saying a ')' is expected.

  ork said:
If you can post your complete usage in the class maybe i can help. You can snip method implementations if they are large to post.

Yep I'll post my code up

  • 0

            // Scenario 1 - Enter cash limit 
            if (aSystem.getCardReader().getCardSatus() == SystemController.CardStatus_Valid)
            {

                Pump aPump = customer1.getPump();
                // Fuel selection
                aPump.setFuelType(FuelPriceType.Unleaded);
                // set cash
                aPump.setPrice(40);       
                // check credit limit
                // check fuel price with customers selection
                if (customer1.getCreditLimit() > aPump.getPrice())
                {
                    double fuelDelivery = aPump.getPrice() / FuelPriceType.UnleadedPrice;

                    aPump.activate();
                    if (aTank.getTotalLevel() > fuelDelivery)
                    {
                        aPump.setFuelDispensed(fuelDelivery);
                    }
                    PrintReceipt(Pump aPump);
                    aPump.deactivate();
                    aTank.removeFuel(fuelDelivery);
                    customer1.setCreditLimit(customer1.getCreditLimit() - aPump.getPrice());
                    DateTime currTime = DateTime.Now;

Correction: it's no longer throwing the original error which I posted about, however, it's still saying that a ')' is expected even when I include the data type (which is Pump in this case)

  • 0

Where abouts is it saying that the ) is expected? I can't see any missing brackets from the code you've posted.

You definitely don't need to include the data type when calling your function. I don't even know how that could compile to be honest since I would think that it would have a bitch about you declaring a variable with the same name in the same scope. (you're basically passing PrintReceipt a blank Pump)

Edit: Go away wrack you crazy fellow. :p

p.s. Hi :p

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Jesus…. dont you know who Jesus is? my god… are you for real?
    • Nope not when you are close to being worth a trillion dollars stop being a simp for billionaires
    • Detective game 'The Operator' is free to claim on the Epic Games Store this week by Pulasthi Ariyasinghe The Epic Games Store's weekly giveaways promotion has just refreshed. Last week's offer of Two Point Hospital has now gone away, and to take its place, the store has brought in The Operator, a detective puzzle game developed by Bureau 81. As always, you have seven days to add the latest game permanently to your Epic Games Store library. Released in 2024, The Operator comes touting an investigation story that puts you into the shoes of a new hire at the Federal Department of Intelligence (FDI), where you are tasked with analyzing evidence, fact-checking, and solving a streak of mysterious crimes using the agency's advanced investigative software. Everything from murders and missing people to cyberattacks are the sort of crimes you'll be investigating throughout the game, all using the agency's unique software console to dig through evidence and personal data. As the story progresses, a conspiracy also comes through from another hacker that paints the FDI in a different light. Here's how the studio teases the hacker's existence even in the game description: The Operator giveaway on the Epic Games Store is now active, and it will last until June 26. When it's not on sale, the game costs $13.99 to purchase, but PC gamers can add it to their library for no cost during the seven-day timeframe. Another PC game will come in as the next freebie on the same day that this entry expires.
    • In Steam, you don't have to bring performance info with some kb combo, it is always there, displayed. A problem with MS design is needs to do a KB combo...that's the problem. XBOX app is a bloatware garbage I remove right away...helps with memory latency.
    • Mangohud has also been doing this since the dawn of time. However, when was the last time the XBOX game bar showed frames from frame generation? Oh, yes. Never.
  • Recent Achievements

    • First Post
      MikeK13 earned a badge
      First Post
    • One Month Later
      OHI Accounting earned a badge
      One Month Later
    • Week One Done
      OHI Accounting earned a badge
      Week One Done
    • First Post
      Thornskade earned a badge
      First Post
    • Week One Done
      Higante88 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      714
    2. 2
      ATLien_0
      272
    3. 3
      Michael Scrip
      203
    4. 4
      +FloatingFatMan
      180
    5. 5
      Steven P.
      128
  • Tell a friend

    Love Neowin? Tell a friend!