Operators
Arithmetic (+ - * /), comparison
(== != > <), and logical
(&& || !) operators work as in most C-family
languages.
Example: a boolean expression, interpolated into output
using System;
class Program {
static void Main() {
int score = 85;
bool passed = score >= 50 && score <= 100;
Console.WriteLine($"Passed: {passed}");
}
}
Passed: True
Notice the capital True in the output — unlike C++ or
Java, C# actually prints its boolean values as the words
True/False directly, no ternary trick needed.
The $"..." syntax is a C# string interpolation, letting
{passed} be evaluated and inserted directly — the same
underlying idea as Python's f-strings or JavaScript's template literals,
just C#'s particular spelling of it.
using System;
class Program {
static void Main() {
int score = 85;
bool passed = score >= 50 && score <= 100;
Console.WriteLine($"Passed: {passed}");
}
}
Passed: True