Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a boolean isEuropean and based on it's value I want to write
isEuropean
Console.WriteLine("This individual is/is not European");
Is it possible in C# to add a conditional directly inside a string with no additional variables created?
bool isEuropean = true; Console.WriteLine($"This individual {(isEuropean ? "is" : "is not")} European");
Yes, you can do string interpolation with a ternary, make sure you contain the ternary in parentheses.
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.