Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 该类型已包含'';_C# - Fatal编程技术网

C# 该类型已包含'';

C# 该类型已包含'';,c#,C#,我正在尝试使contact类表示联系人管理器应用程序中显示的个人联系人,但我不断收到错误消息“cpsc1012\u advanced\u a.contact”类型已包含“ContactTypes”的定义 任何指导都将不胜感激 class Contact { //private member variables private String _firstName; private String _lastName; private Type _contactType

我正在尝试使contact类表示联系人管理器应用程序中显示的个人联系人,但我不断收到错误消息“cpsc1012\u advanced\u a.contact”类型已包含“ContactTypes”的定义

任何指导都将不胜感激

class Contact
{
    //private member variables
    private String _firstName;
    private String _lastName;
    private Type _contactTypes;
    private String _phoneNumber;
    private String _emailAddress;




    //Public constructor that takes five arguments
    public Contact(String firstName, String lastName, Type contactTypes, String phoneNumber, String emailAddress)
    {
        //Call the appropriate setter (e.g. FirstName) to set the member variable value
        FirstName = firstName;
        LastName = lastName;
        ContactTypes = contactTypes;
        PhoneNumber = phoneNumber;
        EmailAddress = emailAddress;

    }


    /*********************************************************************
     * Public accessors used to get and set private member variable values
     *********************************************************************/
    //Public  ContactTypes accessor
    public Type ContactTypes
    {
        get
        {
            //Return member variable value
            return _contactTypes;
        }
        set
        {
            //Validate value and throw exception if necessary
            if (value == "")
                throw new Exception("ContactType must have a value");
            else
                //Otherwise set member variable value
                _lastName = value;
        }
    }
    enum ContactTypes { Family, Friend, Professional }
    //Public FirstName accessor: Pascal casing
    public String GetFirstName
    {
        get
        {
            //Return member variable value
            return _firstName;
        }
        set
        {
            //Validate value and throw exception if necessary
            if (value == "")
                throw new Exception("First name must have a value");
            else
                //Otherwise set member variable value
                _firstName = value;
        }
    }

    //Public LastName accessor: Pascal casing
    public String GetLastName
    {
        get
        {
            //Return member variable value
            return _lastName;
        }
        set
        {
            //Validate value and throw exception if necessary
            if (value == "")
                throw new Exception("Last name must have a value");
            else
                //Otherwise set member variable value
                _lastName = value;
        }
    }



    //Public PhoneNumber accessor
    public String GetPhoneNumber
    {
        get
        {
            //Return member variable value
            return _phoneNumber;
        }
        set
        {
            bool isValid = Regex.IsMatch(value, @"/d{3}-/d{3}-/d{4}");
            //Validate value and throw exception if necessary
            if (value == "")
                throw new Exception("PhoneNumber must have a value");
            else
                //Otherwise set member variable value
                _lastName = value;
        }
    }



    //Public Email accessor
    public String GetEmailAddress
    {
        get
        {
            //Return member variable value
            return _emailAddress;
        }
        set
        {
            //Validate value and throw exception if necessary
            if (value == "")
                throw new Exception("EmailAddress must have a value");
            else
                //Otherwise set member variable value
                _emailAddress = value;
        }
    }

更改此行
enum ContactTypes{Family,Friend,Professional}

enum ContactTypesEnum{Family,Friend,Professional}