???????
????????????????????????????????C#6?????????6???????????仹?????????????????????????????????????????????????????????????????????????????????????Щ??Let’s try it.
????1????????????
//??????????????????????????????????????????????1???
public class Post
{
public DateTime DateCreated { get; private set; }
public List<Comment> Comments { get; private set; }
public Post()
{
DateCreated = DateTime.Now;
Comments = new List<Comment>();
}
}
public class Comment
{
}
//??????????????????????????????????????????????????
public class Post
{
public DateTime DateCreated { get; private set; } = DateTime.Now;
public List<Comment> Comments { get; private set; } = new List<Comment>();
}
public class Comment
{
}
????2???????????
??????????????????ж??????
var dictionary = new Dictionarystring?? string>
{
{ "key1"??"value1"}??
{ "key2"??"value2"}
};
//??????
var dictionary1 = new Dictionarystring?? string>
{
["key1"]="value1"??
["key2"]="value2"
};
????3??string.Format
????????????????????????????????????????string.Format??????StringBuilder?????????????????????????????
Post post = new Post();
post.Title = "Title";
post.Content = "Content";
//????????????????д
string t1= string.Format("{0}_{1}"?? post.Title?? post.Content);
//C#6????????????д???????????$??????????????????
string  t2 = $"{post.Title}_{post.Content}";