1

What is this?

This is a collection of questions that come up every now and then about syntax in C#. This is also a Community Wiki (or has been flagged for such), so everyone is invited to participate in maintaining this list.

Why is this?

Stack Overflow does not allow searching for particular characters. As a consequence, many questions about operators and other syntax tokens are not found easily when searching for them. This also makes closing duplicates more difficult. The list below is to help with this issue.

The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from the C# Spec.

Additionally, this is a blatant copy of the JS reference (and the PHP reference, the CSS reference, etc.). We needed a C# one.


Please help. Edit and add links to other operators/syntax references, or if you can't find good questions/answers on a particular piece of syntax, add an answer to this question and link it

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/243426/discussion-on-question-by-heretic-monkey-what-does-this-symbol-mean-in-c). – Samuel Liew Mar 30 '22 at 03:20

1 Answers1

0

Please do note that a lot of questions about syntax can be answered by reading and searching the C# Language Specification and the more approachable C# Language Reference.

Headings for most syntax will be pulled from that reference, including C# Operators and expressions:

Operators

Arithmetic operators

% Remainder operator

++ Postfix and prefix increment operator

Boolean logical operators

|| and | Conditional and Logical OR operators

&& and & And operators

Bitwise and shift operators

~ Unary bitwise complement operator

<< Binary left shift operator

^ Binary XOR (logical exclusive OR) operator

Equality operators

== Equality operator

Member access operators and expressions

?. Null conditional operator

Type-testing operators and cast expression

is operator/pattern

Assignment operators

op= Compound assignment operators

+= and -= with events/delegates

?? Null coalescing operator

Lambda expressions

=> Lambda declaration operator

=> Expression-bodied members

Other operators

?: Conditional (Ternary) operator

! Null-forgiving operator

:: Namespace alias qualifier

true and false operators

new operator and keyword

Other syntax

typeName? variableName Nullable value types

?[]? Nullable array of nullable reference types

@ before variable names and before string literals

$ before string literals

{0} (or any number) in strings

array[^1] Range and index types

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122