Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected class,delegate,enum,interface or struct

Tags:

c#

class

I am writing a class. I have encountered the problem in the title. Here is the code:

class delivery
{
    private string strDeliveryName;
    private string strDeliveryAddress;
    private string strDeliveryDay;
    private string strDeliveryTime;
    private string strDeliveryMeal;
    private string strDeliveryInstructions;
    private string strDeliveryStatus;
}
public delivery(string deliveryName, string deliveryAddress, string deliveryDay, string deliveryTime, string deliveryMeal, string deliveryInstructions, string deliveryStatus)
    {
        strDeliveryName = deliveryName;
        strDeliveryAddress = deliveryAddress;
        strDeliveryDay = deliveryDay;
        strDeliveryTime = deliveryTime;
        strDeliveryMeal = deliveryMeal;
        strDeliveryInstructions = deliveryInstructions;
        strDeliveryStatus = deliveryStatus;
    }

I get the error on the public delivery, any idea why?

like image 634
sark9012 Avatar asked Mar 05 '26 19:03

sark9012


1 Answers

Your constructor should be within the brackets of the class definition. On an unrelated note, the convention is to capitalize the first letter of class names.

like image 96
unholysampler Avatar answered Mar 08 '26 07:03

unholysampler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!