Hello,
//Error CS1061 //‘Contact.CheckIfUserExists(Contact)’:not all code paths return a value’ //Error CS1061 //‘Contact.GetContactsCount()’:not all code paths return a value’
For the Not All Code Paths Return a Value
error message, it says that your program will not have a return value in all cases.
For example, in the CheckIfUserExists
method, if contacts
is empty and foreach is not executed, the method has no return value.
And in the GetContactsCount
method you commented out the return statement, which must have a corresponding return value for non-void methods.
//x.UserId is highlighted: Error //CS1061 ‘char’ does not contain a definition for ‘UserId’ and no //accessible extension method ‘UserId’ accepting first argument of type //‘char’ could be found (are you missing a directive or an assembly //reference?)
This problem occurs because your InsertContacts
method returns a string, which causes contacts to be a string instead of a list about Contacts, so the x
type is char.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.