博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IEnumerable的应用(即:对于所有数组的遍历,都来自IEnumerable)
阅读量:4210 次
发布时间:2019-05-26

本文共 945 字,大约阅读时间需要 3 分钟。

所有的数组的遍历,都来自于IEnumerable,所以对IEnumerable的遍历
public
static
void
Print(IEnumerable myList)
{
int
i = 0;
foreach
(Object obj
in
myList)
{
if
(obj
is
Student)
//这个是类型的判断,这里Student是一个类或结构
{
Student s=(Student)obj;
Console.WriteLine(
"t[{0}]:t{1}"
, i++, s.Sname);
}
if
(obj
is
int
)
{
Console.WriteLine(
"INT:{0}"
,obj);
}
}
Console.WriteLine();
}
 
 
相关的:
            
if
(args ==
null
)
            
{
                
Console.WriteLine(
"args is null"
);
// Check for null array
            
}
            
else
            
{
                
Console.Write(
"args length is "
);
                
Console.WriteLine(args.Length);
// Write array length
                
for
(
int
i = 0; i < args.Length; i++)
// Loop through array
                
{
                    
string
argument = args[i];
                    
Console.Write(
"args index "
);
                    
Console.Write(i);
// Write index
                    
Console.Write(
" is ["
);
                    
Console.Write(argument);
// Write string
                    
Console.WriteLine(
"]"
);
                
}
            
}
            
Console.ReadLine();
 
            
Console.Write(
"请输入:"
);
            
string
contents = Console.ReadLine();
            
Console.WriteLine(
"刚输入的内容是:"
+ contents +
"——"
+ cTest.Contents);
 
            
Console.Read();

转载地址:http://rozmi.baihongyu.com/

你可能感兴趣的文章
linux 9 -文件系统的压缩与打包 -dump
查看>>
PHP在变量前面加&是什么意思?
查看>>
ebay api - GetUserDisputes 函数
查看>>
ebay api GetMyMessages 函数
查看>>
php加速器 - zendopcache
查看>>
手动12 - 安装php加速器 Zend OPcache
查看>>
set theme -yii2
查看>>
yii2 - 模块(modules)的view 映射到theme里面
查看>>
yii2 - controller
查看>>
yii2 - 增加actions
查看>>
php图像处理函数大全(缩放、剪裁、缩放、翻转、旋转、透明、锐化的实例总结)
查看>>
magento url中 uenc 一坨编码 base64
查看>>
强大的jQuery焦点图无缝滚动走马灯特效插件cxScroll
查看>>
Yii2.0 数据库查询
查看>>
yii2 db 操作
查看>>
mongodb group 有条件的过滤组合个数。
查看>>
关于mongodb的 数组分组 array group
查看>>
MongoDB新的数据统计框架介绍
查看>>
mongodb 增加全文检索索引
查看>>
symfony
查看>>