The type or namespace name ' ' could not be found

时间:2015-07-28 23:58:55

标签: c#

I am trying to build a contact managers program using a list to store and display the data. I need to view a report that displays a summary of contacts available and then have a menu to allow the user to interact with the program. I have a method to create a list with data and a method to create a new contact but my createContact() Method keeps getting the error: The type or namespace name 'ContactTypes' could not be found (are you missing a using directive or an assembly reference?). I am not sure how to fix this

Any guidance would be appreciated

    $(".$id").click(function(e) { 
    e.preventDefault(); 
    $.post("product_details.php", {
        makat : $('#makat').val()
    }, 
        function(data){

        }
    );

Here is my contact class if needed

 static void Main(string[] args)
    {         
        //Declare the list

        List<Contact> contactList = new List<Contact>();

        //Main Driver
        char menuItem;
         Console.WriteLine("Contact List\n");
        menuItem = GetMenuItem();
        while (menuItem != 'Q')
        {

            ProcessMenuItem(menuItem, contactList);
            menuItem = GetMenuItem();

        }
        Console.WriteLine("\nThank you, goodbye");
        Console.ReadLine();
    }
    //Returns either a 'C', 'R', 'U', 'D', 'L', or 'X' to the caller
    static char GetMenuItem()
    {
        char menuItem;
        DisplayMenu();
        menuItem = char.ToUpper(IOConsole.GetChar("\nPlease pick an item: "));
        while (menuItem != 'C'
            && menuItem != 'R' && menuItem != 'Q' && menuItem != 'U' && menuItem != 'D' && menuItem != 'S' && menuItem != 'L' && menuItem != 'F' && menuItem != 'P' && menuItem != 'T')
        {
            Console.WriteLine("\nError - Invalid menu item");
            DisplayMenu();
            menuItem = char.ToUpper(IOConsole.GetChar("\nEnter option or M for menu:"));
        }
        return menuItem;
    }

    static void DisplayMenu()
    {
       Console.WriteLine("C-> Create Contacts");
       Console.WriteLine("R-> Remove Contacts");
       Console.WriteLine("U-> Update Contacts");
       Console.WriteLine("D -> Load data from file");
       Console.WriteLine("S-> Save data to file");
       Console.WriteLine("L-> View sorted by last name");
       Console.WriteLine("F-> View sorted by first name");
       Console.WriteLine("P-> View by partial name search");
       Console.WriteLine("T-> View by contact type");
       Console.WriteLine("Q-> Quit");
    }

    //Routes to the appropriate process routine based on the user menu choice
    static void ProcessMenuItem(Char menuItem, List<Contact> contactList)
    {
        switch (menuItem)
        {
            case 'C':
                createContact();
                break;
            case 'R':
                removeContact(contactList);
                break;
            case 'U':
                updateContact(contactList);
                break;
            case 'D':
                LoadFromFile();
                break;
            case 'S':
                saveToFile();
                break;

            case 'L':
                sortByLastName(contactList);
                break;
            case 'F':
                sortByFirstName(contactList);
                   break;
            case 'P':
                   DisplayList(contactList);
                   break;
            case 'T':
                   sortByContactType();
                   break;
            case 'Q':

                   break;

        }                   
    }

     public static void createContact()
    {
        Contact c1 = new Contact();
        try { 
        Console.WriteLine("\nGetFirstName");
        c1.GetFirstName =  Console.ReadLine();
            }
        catch (System.NullReferenceException)
        {
            Console.WriteLine("Player create failed");
        }
        Console.WriteLine("\nGetLastName");
        c1.GetLastName = Console.ReadLine();
        Console.WriteLine("\nGetEmailAddress");
        c1.GetEmailAddress = Console.ReadLine();
        Console.WriteLine("\nGetPhoneNumber");
        c1.GetPhoneNumber = Console.ReadLine();
        Console.WriteLine("\nContactTypes");
         //ERROR LINE//
        c1.ContactTypes = (ContactTypes)Enum.Parse(typeof(ContactTypes), Console.ReadLine(), true);

        //Create more contacts...

        //Add all contacts here
        ContactCollection contactList = new ContactCollection();
        contactList.Add(c1);

        //Loop through list
        foreach (Contact c in contactList)
        {

            Console.WriteLine(c.GetFirstName);
            Console.WriteLine(c.GetLastName);
            Console.WriteLine(c.GetEmailAddress);
            Console.WriteLine(c.GetPhoneNumber);
            Console.WriteLine(c.ContactTypes);

        }

        Console.ReadLine();

    }

1 个答案:

答案 0 :(得分:0)

You are missing using directive to dat[c(T, diff(dat$x.count)>0), ] # x.id x.timestamp x.count # 71 1 1435114605 61 # 74 1 1435114719 62 's namespace.

Check the namespace of ContactTypes class (apparently Contact also has the same namespace). For instance if it is ContactTypes

Add using in your main class which has the main method. Eg: namespace ContactTypesNamesapce