In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
本篇内容主要讲解"C#数组常用属性和方法有哪些",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"C#数组常用属性和方法有哪些"吧!
C#数组实际上是对象。System.Array 是所有数组类型的抽象基类型。提供创建、操作、搜索和排序数组的方法,因而在公共语言运行库中用作所有数组的基类。因此所有C#数组都可以使用它的属性和方法。
下面介绍一些常用属性和方法:
◆Length属性:表示数组所有维数中元素的总数。
如:
int [] number={1,2,3,4}; number.Length的值为4;
◆Rank属性:表示数组中的维数。
如:
string[,] names = new string[5,4];
names.Rank的值为2。
◆Sort方法:对一维数组排序。它是Array类的静态方法.
如:
string [] name=new string[]{"xi","ang","zhang","chun"}; Array.Sort(name); foreach(string s in name) { Console.WriteLine(s); }
◆Reverse方法:反转一维数组
如
Array.Reverse(name);
◆GetLowerBound与GetUpperBound方法:数组指定维度的下限与上限
如:
int [,,] number=new int[4,3,2]{{{1,2},{2,3},{3,4}},{{4,5},{5,6},
{6,7}},{{7,8},{8,9},{9,10}},{{10,11},{11,12},{12,13}}};
for(int i=number.GetLowerBound(0);i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.