Model == null ?
new SelectList(genders, "Value", "Text") :
new SelectList(genders, "Value", "Text", Model);
I want to avoid writing new SelectList(genders, "Value", "Text" twice, is it possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What happens if you just use
and let it pass in the null reference… is that fourth parameter definitely meant to be non-null?
EDIT: As an alternative, could you use a default value?