c#

路人男主 2016-09-29 09:59:03
public Dictionary<string, object> Attributes
{
get
{
if (this._attributes == null)
{
this._attributes = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
}
return this._attributes;
}
}

谁能解释一下这段代码?谢谢
...全文
69 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
正怒月神 2016-09-29
  • 打赏
  • 举报
回复
首先这是一个封装字段和属性。 应该存在private Dictionary<string, object> _attributes 然后判断_attributes 是否为空,为空就创建这个字典项
全栈极简 2016-09-29
  • 打赏
  • 举报
回复
就是对_attributes泛型字典初始化。后面的StringComparer.InvariantCultureIgnoreCase表示字符串与语言相关的方式忽略大小写。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧