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
Hrides Thakur
NA
292
49.9k
If condition for null checking while setting value in object
Jan 18 2019 6:57 AM
Hello,
I need to use If condition for null checking while setting value in property during object initiliazation
var asset = select new Asset
{
SerialNumber = dr["Serial Number"].ToString(),
Status = dr["Status"].ToString(),
if (convert.ToString( dr["Date"] )!= null)
Date = DateTime.ParseExact((dr["Date"].ToString()), "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture);
}
iwants to do something like I highlighted in red. but it does not allow if condition in property setting.
idont want to create object first and then letter set values, because there is some situations.
is ther any way if i can check null.
Reply
Answers (
3
)
How to sum of HH:MM:SS
How to store files (word,pdf) to mongodb using asp.net c#