Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- /*int[] numbers = new int[5];
- numbers[0] = 1;
- numbers[1] = 5;
- numbers[2] = 8;
- for(int i = 0;i<numbers.Length;i++)
- {
- Console.Write(numbers[i] + " ");
- }
- */
- //or
- /*foreach(int number in numbers)
- {
- Console.Write(number + " ");
- }
- */
- //string[] names = new string[3]{"Thor", "Odin", "Loki"};
- //List
- /*List<int> numbers = new List<int>();
- numbers.Add(5);
- numbers.Add(15);
- numbers.Add(25);
- numbers.Add(35);
- for(int i = 0;i<numbers.Count;i++)
- {
- Console.Write(numbers[i] + " ");
- }
- numbers.RemoveAt(2);
- Console.WriteLine();
- for(int i = 0;i<numbers.Count;i++)
- {
- Console.Write(numbers[i] + " ");
- }
- */
- //Multidimentional array
- CreateGrid();
- }
- public static void CreateGrid()
- {
- int width = 6;
- int height = 5;
- int[,] grid = new int[width,height];
- grid[2,3] = 5;
- for(int x = 0;x<width;x++)
- {
- for(int y = 0;y<height;y++)
- {
- Console.Write(grid[x,y] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment