摘要:
Jeffrey Zhao在"你的字典里有多少元素?"一文中,提到了他在面试时问过的一个问题:List是怎么存放元素?不幸的是,自己也回答不出来,只知道怎么用,却不知道为啥这样用,很明显的"知其然而不知其所以然"。于是,扒了一段List的一段源码来一窥究竟。 using System;using System.Diagnostic;using System.Collections.ObjectMod... 阅读全文
posted @ 2014-07-14 23:26
Darren Ji
阅读(3702)
评论(0)
推荐(3)
摘要:
假设需要为用户创建专属文件夹,文件夹名为用户名,并且需要根据用户类型在不同的文件夹下创建目标文件夹。 在F盘创建"Users"文件夹,在其中创建"Gold"文件夹,用来归类"金牌会员",创建"Silver",用来归类"银牌会员"。 关于用户的Model。 using System.ComponentModel.DataAnnotations;namespace MvcApplication1.... 阅读全文
posted @ 2014-07-14 18:03
Darren Ji
阅读(781)
评论(0)
推荐(0)
摘要:
在项目中,当我们想获取IEnumerable集合的时候,这个集合有可能是null。但通常的做法是返回一个空的集合。 假设有这样一个场景:当商店不营业时,返回一个空的IEnumerable,而当商店正常营业时,就返回一个非空的IEnumerable。 Product模型。 public class Product { public int Id { get; set; } ... 阅读全文
posted @ 2014-07-14 11:39
Darren Ji
阅读(1520)
评论(0)
推荐(1)
浙公网安备 33010602011771号