c#中的GetUpperBound,GetLowerBound方法
今天使用数组的时候,用到了几个数组的属性,总结如下:
Array的Rank 属性:
语法:public int Rank { get; } 得到Array的秩(维数)。
Array的GetUpperBound 方法:
语法:public int GetUpperBound(int dimension) 用于获取 Array 的指定维度的上限。
Array的GetLowerBound方法:
语法:public int GetLowerBound(int dimension) 用于获取 Array 的指定维度的下限。
举例如下:
int []a=new int[3];
这样的话,a.Rank就等于1,表示这是一个一维数组。
string[,] Arr= new string[,]{{"1","2"},{"3","4"},{"5","6"}};
这样的话,Arr.Rank就为2,表示这是一个二维数组
for(int i=Arr.GetLowerBound(0);i<=Arr.GetUpperBound(0);i++)
{
//Arr.GetLowerBound(0);其中的0表示取第一维的下限,一般数组索引是0开始,为0
//同理可得Arr.GetUpperBound(0);其中的0表示取第一维的上限,在本例中是3行2列的数组,所以为3-1=2
for(int j=Arr.GetLowerBound(1);j<=Arr.GetUpperBound(1);j++)
{
//Arr.GetLowerBound(1);其中的1表示取第二维的下限,一般数组索引是0开始,为0
//同理可得Arr.GetUpperBound(1);其中的1表示取第二维的上限,在本例中是3行2列的数组,所以为2-1=1
//遍历数组的元素
Console.write(Arr[i,j]);
}
最新文章
- itrator控制迭代次数
- jQuery实现页内查找相关内容
- Oracle MySQL Server 拒绝服务漏洞
- mysql trouble shooting---- 从库停止同步lock_wait_timeout_exceeded_try_restarting_transaction
- DOS命令(系统错误5,拒绝访问)的解决方法
- QQ互联申请及配置
- 使用jsoup抓取新闻信息
- python字符串-内置方法列举
- 二、Tensorflow的作用域和图
- [M$]微软提供的ProcessExplorer等系统工具集合
- Java中Enumeration接口的用法
- ::before和::after伪元素
- 022.Zabbix自定义(邮箱)脚本告警01
- this inspection reports usage of the default file template for file header
- zw版【转发&#183;台湾nvp系列Delphi例程】HALCON SetComprise1
- 洛谷 P3835: 【模板】可持久化平衡树
- Android学习笔记(3)----手机调试[OFFLINE]的解决方式
- Mysql完全卸载(Windows版本)
- JS获取移动端系统信息(操作系统、操作系统版本、横竖屏状态、设备类型、网络状态、生成浏览器指纹)
- centos6.8服务器配置之编译安装PHP、配置nginx
热门文章
- [JS Compose] 6. Semigroup examples
- 编译nodejs及其源代码研究
- Android NDK对象的引用-全局引用,局部引用,弱引用
- Android addTextChangedListener(文本监听)参数解释及实现EditText字数监听
- [React Router v4] Render Nested Routes
- [Thu, 9 Jul 2015 ~ Tue, 14 Jul 2015] Deep Learning in arxiv
- Elasticsearch v5.4
- 三步学会用spring开发OSGI——(第一步:环境篇)
- 控制器管理UINavigationController、UINavigationBar
- tensorflow 函数接口的理解