I am new to C#. I need to show a users fullname in a console application, but I keep getting this error
Cannot implicitly convert type 'string' to 'UserCustomerNotes.User'
My code works when I only use return user but all that it shows in the app then is "UserCustomerNotes.User" and I need to show the fullname of the user. Can anyone please help. Here is my code:
public static User FindUser(User[] users, int noteid)
{
foreach (User user in users)
if (user.ID == noteid) return user.FullName;
return null;
}
Your method excpecting a return value of typeUser, if you want it to return name - change it to:
public static **string** FindUser(User[] users, int noteid)
or, alternatively:
if (user.ID == noteid) return user;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With