I know I can test the condition and run the code like this:
if (scrapedElement.Contains(".html")
string [] Test = new string[] { scrapedElement, string.empty }
else
string [] Test = new string[] { scrapedElement }
However, I want to do it in a single line if possible. Something similar to this (this is the full line of code that I want it to work in):
File.AppendAllLines(@"C:\Users\DJB\Documents\Visual Studio 2017\Projects\TempFiles\WebScraperExport.csv", new[] { (scrapedElement.Contains(".html") ? scrapedElement, string.Empty : scrapedElement)});
What I am doing is a web scraper that then saves the files in an excel file. For every element it finds that is a link, add a blank line after it, if not just add the element.
This compiled for me and should do what You need
Another alternative that will handle Your case without duplication (but not 1-liner!)