• 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

    • How in the world does the tow truck driver not know someone is back there?
    • Microsoft shares "immediate remediation" script if you deleted this Windows system folder by Sayan Sen Following the Windows 11/10 Patch Tuesday updates for April 2025, users began noticing a new and mysterious "inetpub" folder in the C: directory. What added to the intrigue was that the folder seemed empty for many people, and thus it was assumed that it could be malicious. As such, many users even proceeded to delete the folder. However, as it turns out, Microsoft later confirmed that this folder was indeed part of the April Patch as it was delivered against the CVE-2025-21204 escalation of privilege security vulnerability. Curiously, a security researcher found that interpub itself could also in turn help threat actors permanently block Windows security updates, although, according to the tech giant, it is only categorized as a "moderate" severity at the moment, something that does not require immediate servicing. As such, Microsoft insists that inetpub must not be deleted "irrespective of whether Internet Information Services (IIS) is active." The company shared a new PowerShell script to restore the folder in case you deleted it, adding that it requires "immediate remediation." This reminds us of the recent Defender definition updates that were released for Windows image files against Lumma. In its MSRC advisory, Microsoft cautioned: "For systems with KB5055528 installed but %systemroot%\inetpub directory deleted, immediate remediation is required. If the inetpub directory has been deleted, you need to run the remediation script Set-InetpubFolderAcl.ps1. This script will: Recreate the inetpub directory if it has been deleted. Ensure that the directory permissions are correctly configured to prevent unauthorized access and potential vulnerabilities related to CVE-2025-21204. Update ACLs for the DeviceHealthAttestation directory, if it exists. This directory was created on certain Server versions by the February 2025 security updates. The script will update the ACLs for the DeviceHealthAttestation directory to ensure it is secure." To get the script, users can head over to this page on Microsoft's official PowerShell Gallery website. It should be run with elevated privileges. The page also provides some additional instructions if needed.
  • Recent Achievements

    • Mentor
      Karlston went up a rank
      Mentor
    • One Month Later
      EdwardFranciscoVilla earned a badge
      One Month Later
    • One Month Later
      MoyaM earned a badge
      One Month Later
    • One Month Later
      qology earned a badge
      One Month Later
    • One Year In
      Frinco90 earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      489
    2. 2
      snowy owl
      258
    3. 3
      +FloatingFatMan
      253
    4. 4
      ATLien_0
      217
    5. 5
      Xenon
      152
  • Tell a friend

    Love Neowin? Tell a friend!