A conditional statement is literally just a "compressed"
if
...
else
statement:
if (a)
b;
else
c;
And it becomes
a ? b : c
But it's intended for assignments so it really needs the "expanded" version to be something like this:
if (a)
x = b;
else
x = c;
Which becomes
x = a ? b : c
As a result, both the
b
and
c
parts of the conditional statement must return the same types
Your original code isn't an assignment, so your "compressed" version doesn't do the same thing and probably should be something like
subscribers.Add(DmApiCacheUpdateStrategy.Equals("Delete")) ?
new Subscriber()
{
Arguments = DmProject.GetDmProjectPath(dmProject),
ExecutablePath = _apiDataPublisher.IeconPath,
PostExecutionAction = _apiDataPublisher.OldFileCleanup
} :
new Subcriber()
{
...
Except that your original doesn't add an item in all cases so you can't convert the whole thing to a conditional statement at all!
Even if you could, the code you would end up with would be pretty impenetrable to read compared to the
if
...
else
version, so I woudln't do it at all if I was you.