Clipboard.SetText(txtBox1.Text);
How can I use a ternary operator here to set the text of the clipboard to txtbox1.Text if txtbox1.Text is not equal to string null, (nothing) ?
Thanks
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.
You cannot. You are calling “SetText” either way. The correct way to achieve that would be to not call SetText if the text is not null.
Using Clipboard.SetText( a ? b : c); would give you nothing here if you dont want to set the text (only except hoping that SetText would ignore a null) unless you want some default. in that case something like: