TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hakan Axheim
NA
201
32.4k
System.Collections.Generic.List<T>.Find(...) returned null.
Oct 23 2020 2:28 AM
Hi,
In the source code I am working with a List containting items from a table in SqlServer.
I wantt to search for a specific item in that list with a unique ID.
When I search for a value that not exist in that List the result will be null and I receive an exception.
This is the source code:
string resultValue = ItemList.Find(Item => Item.Id.equals(searchId)).Name;
If I search for a value (searchId) that doesn't exist in ItemList than an error occurs that the object System.NullReferenceException: Objectreferens not set ...
How do I solve this problem?
In my version of C# I cannot use Nullable variables.
Reply
Answers (
2
)
How to secure asp.net core web application?
Check availability of usernames in database and validate