Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I am finally getting the hang of doubly linked lists!
Although kind of confused as to what way i can edit my code to Display an output saying whether or not the Node was found when a user searched for it.

This is what i have so far as my Find method.

C#
public Node Find(object n) // finds a node in the DLL
            {
                
                current = head;
                while ((current != null) && (current.data != n))
                    current = current.next;

                if (current == null)
                {

                    return null;                  
                }
                else
                    return current;
            }


I was thinking of adding a string component to it but not sure the best way to go about it?
Posted
Updated 17-Feb-14 21:48pm
v2

1 solution

Use variable:

Node node =Find(2);
if(node==null)
Printf("Not Found");
else
Printf("Found");

or modify your function by adding the above line of code in that function to display the message
 
Share this answer
 
Comments
Member 10540766 16-Feb-14 17:59pm    
Im not sure i understand what you mean?
Printf would not output anything either

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900