yield关键字, default关键字, 别名关键字
1.yield返回IEnumberable接口对象,使其可以支持foreach迭代。
yeild return用于返回值,yeild break用于中断迭代。
迭代器的返回类型必须为IEnumerable、IEnumerator、IEnumerable<T>或IEnumerator<T>。
如:
public class YieldTest
{
public static IEnumerable Power(int number, int exponent)
{
int counter = 0;
int result = 1;
while (counter++ < exponent)
{
result = result * number;
yield return result;
}
}
}
{
public static IEnumerable Power(int number, int exponent)
{
int counter = 0;
int result = 1;
while (counter++ < exponent)
{
result = result * number;
yield return result;
}
}
}
2. default(int)
3.using colAlias = System.Collections;
colAlias::Hashtable test = new colAlias::Hashtable();