Is there a keyword to ‘do nothing’ in C#?
For example I want to use a ternary operator where one of the actions is to take no action:
officeDict.ContainsKey("0") ? DO NOTHING : officeDict.Add("0","")
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.
No, there is no such keyword. Besides, the
?:operator is not meant for deciding actions. It’s meant for deciding values (or, more technically, value expressions).You really, really want to use an if condition for this sort of decision-making instead: