当前位置: 首页>>代码示例>>C#>>正文


C# Int16.GetLength方法代码示例

本文整理汇总了C#中System.Int16.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Int16.GetLength方法的具体用法?C# Int16.GetLength怎么用?C# Int16.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Int16的用法示例。


在下文中一共展示了Int16.GetLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getLevel

 //reads csv into an int16, also supports bool-based legacy levels.
 public static Int16[,] getLevel(string s)
 {
     String[,] raw = readCSV(s);
     Int16[,] ints = new Int16[raw.GetLength(0), raw.GetLength(1)];
     for (int i = 0; i < ints.GetLength(0); i++)
     {
         for (int j = 0; j < ints.GetLength(1); j++)
         {
             try
             {
                 ints[i, j] = Convert.ToInt16(raw[i, j]);
             }
             catch
             {
                 if (raw[i, j] == "true")
                 {
                     ints[i, j] = 1;
                 }
                 else
                 {
                     ints[i, j] = 0;
                 }
             }
         }
     }
     return ints;
 }
开发者ID:scarbunkle,项目名称:spnmario,代码行数:28,代码来源:CSVRead.cs

示例2: Level

 //advanced constructor
 public Level(Texture2D dirt, Int16[,] vals)
 {
     height = vals.GetLength(0);
     length = vals.GetLength(1);
     tL = new Tile[height, length];
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < length; j++)
         {
             tL[i, j] = new Tile(new Rectangle(tileSide * j, tileSide * i, tileSide, tileSide), dirt, vals[i, j]);
         }
     }
 }
开发者ID:scarbunkle,项目名称:spnmario,代码行数:14,代码来源:Level.cs

示例3: CompareArray

        public static void CompareArray( Int16[] expected, Int16[] actual )
        {
            Assert.AreEqual(expected.Length, actual.Length, "The array should have the correct number of elements.");

            for ( Int32 rowIndex = 0; rowIndex < expected.GetLength(0); rowIndex++ ) {
                Assert.AreEqual(expected[rowIndex], actual[rowIndex], "The element at index ({0}) (zero-based) should be correct.", rowIndex);
            }
        }
开发者ID:LiveOak,项目名称:NlsyLinksDetermination,代码行数:8,代码来源:Helpers.cs

示例4: EqualsTest

 public void EqualsTest()
 {
     var data = new Int16[,] { { 0, 0 }, { -1, -1 }, { 1, 1 } };
     var length = data.GetLength(0);
     for (var i = 0; i < length; i++)
     {
         InteropInt16 interopInt16 = data[i, 0];
         InteropInt16 interopInt162 = data[i, 1];
         Assert.IsTrue(interopInt16.Equals(interopInt162));
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:InteropInt16Test.cs

示例5: runTest

 public Boolean runTest()
   {
   Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   String strBaseLoc;
   short[] in2Arr = new Int16[10]; 
   int[] in4Arr = new Int32[5]; 
   long[] in8Arr = new Int64[0]; 
   String[] strArr = new String[6]; 
   Boolean[] boArr = new Boolean[3]; 
   Double[] dblArr = new Double[2]; 
   Single[] snglArr = new Single[32000]; 
   Char[] chArr = new Char[10000]; 
   int rank;
   try {
   LABEL_860_GENERAL:
   do
     {
     strLoc = "Loc_819yt";
     rank = -1;
     in2Arr = new Int16[5];
     iCountTestcases++;
     try {
     in2Arr.GetLength(rank);
     iCountErrors++;
     Console.WriteLine( s_strTFAbbrev+ "Err_499ws! , GetLength=="+in2Arr.Length);
     } catch (IndexOutOfRangeException ioorExc) {}
     catch (Exception exc) {
     iCountErrors++;
     Console.WriteLine( s_strTFAbbrev+ "Err_758! exc=="+exc);
     }
     strLoc = "Loc_819ee";
     rank = 1;
     in2Arr = new Int16[5];
     iCountTestcases++;
     try {
     in2Arr.GetLength(rank);
     iCountErrors++;
     Console.WriteLine( s_strTFAbbrev+ "Err_500ws! , GetLength=="+in2Arr.Length);
     } catch (IndexOutOfRangeException ioorExc) {}
     catch (Exception exc) {
     iCountErrors++;
     Console.WriteLine( s_strTFAbbrev+ "Err_750! exc=="+exc);
     }
     strLoc = "Loc_482wu";
     rank = 0;
     in2Arr = new Int16[10];
     iCountTestcases++;
     if(in2Arr.GetLength(rank) != 10)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_481ua! , GetLength=="+in2Arr.Length);
       }
     strLoc = "Loc_471ay";
     in4Arr = new Int32[5];
     iCountTestcases++;
     if(in4Arr.GetLength(rank) != 5)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_29qaq! , GetLength=="+in4Arr.Length);
       }
     strLoc = "Loc_982uq";
     in8Arr = new Int64[0];
     iCountTestcases++;
     if(in8Arr.GetLength(rank) != 0)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_237sy! , GetLength=="+in8Arr.Length);
       }
     strLoc = "Loc_172ms";
     boArr = new Boolean[3];
     iCountTestcases++;
     if(boArr.GetLength(rank) != 3)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_382! , GetLength=="+boArr.Length);
       }
     strLoc = "Loc_49su";
     dblArr = new Double[2];
     iCountTestcases++;
     if(dblArr.GetLength(rank) != 2)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_200su! , GetLength=="+dblArr.Length);
       }
     strLoc = "Loc_371su";
     snglArr = new Single[32000];
     iCountTestcases++;
     if(snglArr.GetLength(rank) != 32000)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_319aw! , GetLength=="+snglArr.Length);
       }
     strLoc = "Loc_129wi";
     strArr = new String[5];
     strArr[2] = null;
     iCountTestcases++;
     if(strArr.GetLength(rank) != 5)
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5127getlength_int.cs

示例6: IsEqual

        public static bool IsEqual(this Int32[,] a, Int16[][] b, Int32 atol = 0, Double rtol = 0)
        {
    if (a == null && b == null)
        return true;
    if (a == null ^ b == null)
        return false;
    int[] la = a.GetLength(true);
    int[] lb = b.GetLength(true);
    if (la.Length != lb.Length)
        return false;
    for (int i = 0; i < la.Length; i++)
        if (la[i] != lb[i])
            return false;

            if (rtol > 0)
            {
                for (int i = 0; i < b.Length; i++)
                    for (int j = 0; j < b[i].Length; j++)
{
    var A = a[i, j];
    var B = b[i][j];
    if (A == B)
        continue;
    var C = A;
    var D = B;
    var delta = Math.Abs(C - D);
    if (C == 0)
    {
        if (delta <= rtol)
            continue;
    }
    else if (D == 0)
    {
        if (delta <= rtol)
            continue;
    }

    if (delta <= Math.Abs(C) * rtol)
        continue;
    return false;
}

            }
            else if (atol > 0)
            {
                for (int i = 0; i < b.Length; i++)
                    for (int j = 0; j < b[i].Length; j++)
{
    var A = a[i, j];
    var B = b[i][j];
    if (A == B)
        continue;
    var C = A;
    var D = B;
    if (Math.Abs(C - D) <= atol)
        continue;
    return false;
}

            }
            else
            {
                for (int i = 0; i < b.Length; i++)
                    for (int j = 0; j < b[i].Length; j++)
{
    var A = a[i, j];
    var B = b[i][j];
    if (A != B)
        return false;
}

            }

            return true;
        }
开发者ID:accord-net,项目名称:framework,代码行数:75,代码来源:Matrix.Comparisons1.Generated.cs


注:本文中的System.Int16.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。