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


C# Int32.GetLength方法代码示例

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


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

示例1: ToBitmap

 public static unsafe Bitmap ToBitmap(Int32[,] pole)
 {
     Bitmap b;
     fixed(int* pp = &pole[0,0])
      b= new Bitmap(pole.GetLength(1), pole.GetLength(0),pole.GetLength(1)*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb,(IntPtr)pp);
     return b;
 }
开发者ID:Gaunt,项目名称:Soft3D,代码行数:7,代码来源:Soft3DBitmap.cs

示例2: TexturedTriangle

 //vytvori otexturovany trojuhelnik z t, s texturou texture namapovanou podle coords
 public TexturedTriangle(Triangle3D t,Triangle2D coords,Int32[,] texture)
     : base(t.V1,t.V2,t.V3)
 {
     texcoords = coords;
     bitmap = texture;
     width = texture.GetLength(0);
     height = texture.GetLength(1);
     port = new Viewport(1,1,width,width);
 }
开发者ID:Gaunt,项目名称:Soft3D,代码行数:10,代码来源:TexturedTriangle.cs

示例3: Main

        static void Main(string[] args)
        {
            var stream = Console.In;
            string line;
            while ((line = stream.ReadLine()) != null)
            {
                File.AppendAllLines("debug.txt", new[] {line});
                var strings = line.Split(' ');
                var planets = Int32.Parse(strings[0]);
                var earthIndex = Int32.Parse(strings[1]);
                var atlantisIndex = Int32.Parse(strings[2]);
                var distances = new Int32[planets,planets];
                _initializeDistances(distances);

                for (int i = 3; i < strings.Length; i++)
                {
                    var aux = strings[i].Split(',');
                    if (aux.Length != 3) continue;
                    distances[Int32.Parse(aux[0]), Int32.Parse(aux[1])] = Int32.Parse(aux[2]);
                }

                List<BellmanFord.Vertex> vertices = new List<BellmanFord.Vertex>();
                for (int i = 0; i < planets; i++)
                {
                    vertices.Add(new BellmanFord.Vertex() { id = i});
                }

                List<BellmanFord.Edge> edges = new List<BellmanFord.Edge>();
                for (int i = 0; i < distances.GetLength(0); i++)
                {
                    for (int z = 0; z < distances.GetLength(1); z++)
                    {
                        edges.Add(new BellmanFord.Edge()
                                      {
                                          Source = vertices[i],
                                          Destination = vertices[z],
                                          Weight = Int32.MaxValue == distances[i,z] ? Double.PositiveInfinity : distances[i,z]
                                      });
                    }
                }

                try
                {
                    BellmanFord.Run(vertices, edges,  vertices[earthIndex]);
                    Console.WriteLine(25000 + vertices[atlantisIndex].Distance);

                }
                catch (Exception e)
                {
                    Console.WriteLine("BAZINGA");
                }
                if (stream.Peek() == -1) break;
            }
        }
开发者ID:fmanso,项目名称:Tuenti-Contest-2k11,代码行数:54,代码来源:C12-StargateProblem.cs

示例4: Soft3DScreen

        private double[,] zbuffer; //pamet hloubky

        #endregion Fields

        #region Constructors

        //nastavi promenne na defaultni hodnoty.
        //parametrem bitmap se predava odkaz na bitmapu do ktere se bude kreslit
        public Soft3DScreen(Int32[,] bitmap)
        {
            screen = bitmap;
            screenHeight = bitmap.GetLength(1);
            screenWidth = bitmap.GetLength(0);
            zbuffer = new double[screenWidth, screenHeight];
            for(int i = 0;i<screenWidth;i++)
              for(int j = 0;j<screenHeight;j++)
                zbuffer[i,j] = 1;//inicializace z bufferu na max hodnotu

            projection = new Projection(Math.PI/4,(double)screenWidth/(double)screenHeight,
            2.4,50);//nastaveni projekce,zorny uhel je 45 stupnu
            viewport = new Viewport(2,2,
                        screenWidth,screenHeight);
            byte[] white = {255,255,255,255};
            color = BitConverter.ToInt32(white, 0);
            viewMatrix=Matrix44.GetIdentityMatrix();
        }
开发者ID:Gaunt,项目名称:Soft3D,代码行数:26,代码来源:.Soft3dScreen.cs

示例5: EqualsTest

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

示例6: Main

        static void Main(string[] args)
        {
            int[,] ladder = new Int32[,] {
            {1,38},{4,14},{9,31},{21,42},{28,84},{51,67},{71,91},{80,100}
            };

            int[,] snake = new Int32[,]{
            {17,7},{54,34},{62,19},{64,60},{87,24},{93,73},{95,75},{98,79}
            };
            int i = 0;
            int j = 0;
            int your_turn;

            Console.WriteLine("Ïnput -> How many players in games:\t");
            int user_no = Convert.ToInt16(Console.ReadLine());

            int[,] user_array = new int[user_no, 2]; //how many users will be involved in snake gme

            // store users into array
            for (i = 0; i < user_no; i++)
            {
                for (j = 0; j < 2; j++)
                {
                    if (j == 0)
                        user_array[i, j] = i + 1;
                    else
                        user_array[i, j] = 0;
                    //Console.WriteLine(user_array[i,j]);
                }
            }

            int goal = 0;
            while (goal < 100) // winner stage
            {
                for (i = 0; i < user_no; i++) // need to make one by one
                {

                    if (user_array[i, 1] >= 100) // get user step from array to check goal or not
                    {
                        goal = 100;
                        break; // Reached point
                    }

                    else // if not reach goal, go on
                    {

                        int turn = 0; // we need to go one by on. Don't make two twice.

                        while (turn != i + 1) // we need to go one by on. Don't make two twice.
                        {
                            Console.Write("\nEnter Your turn:\t");
                            your_turn = Convert.ToInt16(Console.ReadLine());// now. who is turn?

                            if (your_turn == i + 1)
                            {
                                Random rnd = new Random(); // declare random number
                                int rnd_no = rnd.Next(1, 6); // get one random number

                                Console.WriteLine("Your existing step is " + user_array[i, 1] + "\n");

                                user_array[i, 1] += rnd_no;

                                turn = i + 1; // 1; end while; let's go to for loop

                                for (int a = 0; a < ladder.GetLength(0); a++)
                                {

                                    if (ladder[a, 0] == user_array[i, 1])
                                    {
                                        //    Console.WriteLine("Random number is " + rnd_no+"\nCongrat!!!!!  You get a ladder:   "+ladder[a,1]);
                                        Console.WriteLine("\nCongrat!!!!!  You get a ladder:   " + ladder[a, 1]);
                                        user_array[i, 1] = ladder[a, 1];

                                        //    Console.WriteLine("You reached here:   " + user_array[i,1]);
                                    }
                                    if (snake[a, 0] == user_array[i, 1])
                                    {
                                        //    Console.WriteLine("Random number is " + rnd_no + "\nYou get a snake:   " + snake[a, 1]);
                                        Console.WriteLine("\nYou get a snake:   " + snake[a, 1]);
                                        user_array[i, 1] = snake[a, 1];
                                        //    Console.WriteLine("You reached here:   " + user_array[i, 1]);
                                    }
                                }

                                if (user_array[i, 1] > 100)
                                {
                                    int value = user_array[i, 1] - 100;
                                    int value1 = 100 - value;
                                    user_array[i, 1] = value1;
                                    Console.WriteLine("Because of Random number is " + rnd_no + "\nPlayer: " + (i + 1) + " *******Now Your Step is " + user_array[i, 1] + "\n"); // show user your step

                                }
                                else if (user_array[i, 1] == 100) // for check to get goal
                                {
                                    goal = 100;
                                    // show user your step
                                    Console.WriteLine("Because of Random number is " + rnd_no + "\nPlayer: " + (i + 1) + " *** Now Your Step is  " + user_array[i, 1] + "\n");

                                    i = user_no + user_no;      // for break while and for
                                    turn = i + 1;               // for break while and for
//.........这里部分代码省略.........
开发者ID:shweyeeaungtoe,项目名称:CSExercises,代码行数:101,代码来源:SnakeGame.cs

示例7: 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

示例8: IsEqual

        public static bool IsEqual(this Int16[][] a, Int32[][] 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 < a.Length; i++)
                    for (int j = 0; j < a[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 < a.Length; i++)
                    for (int j = 0; j < a[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 < a.Length; i++)
                    for (int j = 0; j < a[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

示例9: GetType

 private Type GetType(StringBuilder typeName, Int32[] positions, Int32 i, Char c)
 {
     Int32 length = positions.GetLength(0);
     Type type;
     if (i < length) {
         typeName[positions[i++]] = c;
         type = GetType(typeName, positions, i, '.');
         if (i < length) {
             if (type == null) {
                 type = GetType(typeName, positions, i, '_');
             }
             if (type == null) {
                 type = GetNestedType(typeName, positions, i, '+');
             }
         }
     }
     else {
         type = GetType(typeName.ToString());
     }
     return type;
 }
开发者ID:bluelovers,项目名称:phprpc,代码行数:21,代码来源:PHPReader.cs

示例10: GetMovementSprites

        /// <summary>
        /// Gets a serie of sprites according to movement offsets
        /// </summary>
        /// <param name="block">base block</param>
        /// <param name="movements">wall kicks</param>
        /// <param name="baseRotation">original rotation</param>
        /// <param name="iteration">display iteration</param>
        protected virtual List<Sprite> GetMovementSprites(Data.Block block, Int32[,] movements, Int32 baseRotation, Int32 iteration)
        {
            var sprites = new List<Sprite>();

            for (Int32 j = 0; j < movements.GetLength(0); j++)
            {
                // Grid
                sprites.Add(
                    new SpriteField(this.Game, _field)
                    {
                        Position = this.Position + SpriteField.GridCellSize * ((_field.Width + 1) * j) * Vector2.UnitX +
                            SpriteField.GridCellSize * ((_field.Height - SpriteField.HiddenRows + 1) * iteration) * Vector2.UnitY,
                    }
                );

                // Block boundary
                sprites.Add(
                    new Sprite(this.Game)
                    {
                        TextureName = "Graphics/blank",
                        Size = Vector2.One * SpriteField.GridCellSize * block.Width,
                        Position = this.Position + SpriteField.GridCellSize * (2 + (_field.Height - SpriteField.HiddenRows + 1) * iteration) * Vector2.UnitY +
                            SpriteField.GridCellSize * (2 + (_field.Width + 1) * j) * Vector2.UnitX,
                        Opacity = 0.1f,
                        Color = Color.White,
                    }
                );

                // Add base sprite
                var baseBlock = (Data.Block)block.Clone();
                baseBlock.Rotation = baseRotation;

                sprites.Add(
                    new SpriteFallingBlock(this.Game,
                        new Data.FallingBlock(this.Game, baseBlock, _field, 2, block.Height + 1)
                    )
                    {
                        Position = this.Position + SpriteField.GridCellSize * ((_field.Height - SpriteField.HiddenRows + 1) * iteration) * Vector2.UnitY +
                            SpriteField.GridCellSize * ((_field.Width + 1) * j) * Vector2.UnitX,
                        Opacity = 0.2f,
                    }
                );

                // Add kicked sprite
                sprites.Add(
                    new SpriteFallingBlock(this.Game,
                        new Data.FallingBlock(this.Game, (Data.Block)block.Clone(), _field,  2 + movements[j, 0], block.Height + 1 + movements[j, 1])
                    )
                    {
                        Position = this.Position + SpriteField.GridCellSize * ((_field.Height - SpriteField.HiddenRows + 1) * iteration) * Vector2.UnitY +
                            SpriteField.GridCellSize * ((_field.Width + 1) * j) * Vector2.UnitX
                    }
                );
            }

            return sprites;
        }
开发者ID:thexa4,项目名称:time-tetris,代码行数:64,代码来源:SpritesetWallkick.cs

示例11: has4NumbersLeftDiag

 static Boolean has4NumbersLeftDiag(int x, int y, Int32[,] grid)
 {
     var lengthDown = grid.GetLength(y);
     return (lengthDown - 4 < 0);
 }
开发者ID:longje,项目名称:Project-Euler,代码行数:5,代码来源:Problem11.cs

示例12: PatternFill

        /// <summary>
        /// Создает экземпляр PatternFill.
        /// </summary>
        /// <param name="pattern">Таблица значений пиекселй шаблона</param>
        /// <param name="originX">Координата x начала отсчета</param>
        /// <param name="originY">Координата y начала отсчета</param>
        public PatternFill(Int32[,] pattern, int originX, int originY)
        {
            if (pattern.GetLength(0) == 0 || pattern.GetLength(1) == 0)
                throw new ArgumentException("pattern");

            _pattern = pattern;
            _originX = originX;
            _originY = originY;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:15,代码来源:Fills.cs


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