最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

c# Rank屬性與GetUpperBound方法的深入分析

 更新時(shí)間:2013年06月08日 15:41:41   作者:  
本篇文章是對(duì)c#中的Rank屬性與GetUpperBound方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
Array的Rank 屬性:
   語(yǔ)法:public int Rank { get; }   得到Array的秩(維數(shù))。
Array而GetUpperBound 方法:
   語(yǔ)法:public int GetUpperBound(int dimension)  用于獲取 Array 的指定維度的上限。
--------------------------------------------------------------------------------
示例:
復(fù)制代碼 代碼如下:

using System;
 public class SamplesArray  {
    public static void Main()  {
       // Creates a new one-dimensional Array of type Int32.
       Array my1DIntArray = Array.CreateInstance( typeof(Int32), 5 );
       // Uses GetLowerBound and GetUpperBound in the for loop.
       for ( int i = my1DIntArray.GetLowerBound(0); i <= my1DIntArray.GetUpperBound(0); i++ )
          my1DIntArray.SetValue( i+1, i );
       // Displays the bounds and values of the one-dimensional Array.
       Console.WriteLine( "One-dimensional Array:" );
       Console.WriteLine( "Rank/tLower/tUpper" );
       Console.WriteLine( "{0}/t{1}/t{2}", 0, my1DIntArray.GetLowerBound(0), my1DIntArray.GetUpperBound(0) );
       Console.WriteLine( "Values:" );
       PrintValues( my1DIntArray );
       Console.WriteLine();
       // Creates a new three-dimensional Array of type Int32.
       Array my3DIntArray = Array.CreateInstance( typeof(Int32), 2, 3, 4 );
       // Uses GetLowerBound and GetUpperBound in the for loop.
       for ( int i = my3DIntArray.GetLowerBound(0); i <= my3DIntArray.GetUpperBound(0); i++ )
          for ( int j = my3DIntArray.GetLowerBound(1); j <= my3DIntArray.GetUpperBound(1); j++ )
             for ( int k = my3DIntArray.GetLowerBound(2); k <= my3DIntArray.GetUpperBound(2); k++ )  {
                my3DIntArray.SetValue( (i*100)+(j*10)+k, i, j, k );
             }
       // Displays the bounds and values of the multidimensional Array.
       Console.WriteLine( "Multidimensional Array:" );
       Console.WriteLine( "Rank/tLower/tUpper" );
       for ( int i = 0; i < my3DIntArray.Rank; i++ )
          Console.WriteLine( "{0}/t{1}/t{2}", i, my3DIntArray.GetLowerBound(i), my3DIntArray.GetUpperBound(i) );
       Console.WriteLine( "Values:" );
       PrintValues( my3DIntArray );
    }
    public static void PrintValues( Array myArr )  {
       System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();
       int i = 0;
       int cols = myArr.GetLength( myArr.Rank - 1 );
       while ( myEnumerator.MoveNext() )  {
          if ( i < cols )  {
             i++;
          } else  {
             Console.WriteLine();
             i = 1;
          }
          Console.Write( "/t{0}", myEnumerator.Current );
       }
       Console.WriteLine();
    }
 }
 /*
 This code produces the following output.
 One-dimensional Array:
 Rank    Lower    Upper
 0    0    4
 Values:
     1    2    3    4    5
 Multidimensional Array:
 Rank    Lower    Upper
 0    0    1
 1    0    2
 2    0    3
 Values:
     0    1    2    3
     10    11    12    13
     20    21    22    23
     100    101    102    103
     110    111    112    113
     120    121    122    123
*/

相關(guān)文章

  • C#對(duì)Xamarin框架進(jìn)行數(shù)據(jù)綁定

    C#對(duì)Xamarin框架進(jìn)行數(shù)據(jù)綁定

    這篇文章介紹了C#對(duì)Xamarin框架進(jìn)行數(shù)據(jù)綁定,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-01-01
  • C#基于WebSocket實(shí)現(xiàn)聊天室功能

    C#基于WebSocket實(shí)現(xiàn)聊天室功能

    這篇文章主要為大家詳細(xì)介紹了C#基于WebSocket實(shí)現(xiàn)聊天室功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • C#隨機(jī)生成Unicode類型字符串

    C#隨機(jī)生成Unicode類型字符串

    做測(cè)試時(shí)經(jīng)常需要生成一些隨機(jī)數(shù)據(jù),最常見(jiàn)的就是生成隨機(jī)字符串。而且往往要生成Unicode字符串,有時(shí)還要特別指定生成的字符的語(yǔ)言范圍。下面是我覺(jué)得比較靈活的方法:
    2013-04-04
  • C# 多線程處理List數(shù)據(jù)的示例代碼

    C# 多線程處理List數(shù)據(jù)的示例代碼

    這篇文章主要介紹了C# 多線程處理List數(shù)據(jù)的示例代碼,幫助大家更好的理解和使用c#編程語(yǔ)言,感興趣的朋友可以了解下
    2020-12-12
  • C#工程建立后修改工程文件名與命名空間操作

    C#工程建立后修改工程文件名與命名空間操作

    這篇文章主要介紹了C#工程建立后修改工程文件名與命名空間操作,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-06-06
  • c# HashSet的擴(kuò)容機(jī)制需要注意的

    c# HashSet的擴(kuò)容機(jī)制需要注意的

    這篇文章主要介紹了c# HashSet的擴(kuò)容機(jī)制需要注意的兩個(gè)地方,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • C#基于JsonConvert解析Json數(shù)據(jù)的方法實(shí)例

    C#基于JsonConvert解析Json數(shù)據(jù)的方法實(shí)例

    最近初接觸C#語(yǔ)言,發(fā)現(xiàn)JSON解析這塊和JAVA差異過(guò)大,下面這篇文章主要給大家介紹了關(guān)于C#基于JsonConvert解析Json數(shù)據(jù)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • C#中把Datatable轉(zhuǎn)換為Json的5個(gè)代碼實(shí)例

    C#中把Datatable轉(zhuǎn)換為Json的5個(gè)代碼實(shí)例

    這篇文章主要介紹了C#中把Datatable轉(zhuǎn)換為Json的5個(gè)代碼實(shí)例,需要的朋友可以參考下
    2014-04-04
  • C#的靜態(tài)工廠方法與構(gòu)造函數(shù)相比有哪些優(yōu)缺點(diǎn)

    C#的靜態(tài)工廠方法與構(gòu)造函數(shù)相比有哪些優(yōu)缺點(diǎn)

    這篇文章主要介紹了C#的靜態(tài)工廠方法與構(gòu)造函數(shù)對(duì)比的優(yōu)缺點(diǎn),文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • DataGridView設(shè)置單元格的提示內(nèi)容ToolTip

    DataGridView設(shè)置單元格的提示內(nèi)容ToolTip

    這篇文章介紹了DataGridView設(shè)置單元格提示內(nèi)容ToolTip的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-02-02

最新評(píng)論

闻喜县| 文登市| 延边| 伊通| 仪征市| 兰溪市| 铜鼓县| 饶河县| 道孚县| 郴州市| 措美县| 沅江市| 开化县| 酉阳| 石柱| 琼海市| 上思县| 都匀市| 安庆市| 都兰县| 三原县| 松溪县| 宁陕县| 莲花县| 宣威市| 新蔡县| 洞头县| 布拖县| 洪洞县| 南乐县| 邵武市| 古田县| 读书| 巴东县| 靖安县| 泸西县| 石楼县| 双流县| 和静县| 虞城县| 大城县|