I need to write a syntax which uses (single line if) statement, but I need to nest it in the sense:
(expression 1)?
(if expression 2 throws ArgumentException then string.empty else expression2):string.empty
So Basically I need to figure out a syntax of using try catch inside single line if statement in c# (single line because I need to use it in a linq to sql select statement.)
By single line if statement I mean using ternary operator if statements without having any semicolon.
are you looking for something like this?
with foo being:
As far as embedding Try/Catch into a Linq to Sql statement … Well let’s just say I’d try and rethink my design in that case.