开发者

expected class,delegate,enum,interface or struct

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, strin开发者_JS百科g 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?


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.


Your constructor code is not inside the class. Move it inside and all should be fine. :-)


To answer your second question (in the comment), you need to change the name of the constructor to match the name of the class.


This error is because you have declared the function outside of the main class. You should insert your code inside the main class.


I received this error because I accidentally missed an open brace in code above where the error occurred. This meant the class ended prematurely. So if you get this error maybe check that your braces are correct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜