C 6 Cheat Sheet
C 6 Cheat Sheet
C 6 Cheat Sheet
programmingwithmosh.com
Auto-property initializers
public
class
Post
{
public
Collection<Comment>
Comments
{
get;
private
set;
}
=
new
Collection<Comment>();
}
Dictionary initializers
var
dictionary
=
new
Dictionary<string,
string>
{
[“LAX”]
=
“Los
Angeles
Int’l
Airport”
}
String interpolation
var
fullName
=
$”{firstName}
{lastName}”;
Null-conditional operator
int?
count
=
post?.Tags?.Count;
int
count
=
post?.Tags?.Count
??
0;
Getter-only auto-properties
public
class
Post
{
public
int
Votes
{
get;
}
//
no
“private
set”
}