Rabu, 23 Maret 2016

Cara Membuat Array dalam C#


cara membuat Array dalam c#
1. buka visual studio
2. new project
3. Kliik " Console Application" Visual C#

lalu akan muncul form seperti ini :

 
langsung saca mnekoding dengn cara mengeketik


            int[] myInts = { 5, 10, 15 };
            bool[][] myBools = new bool[2][];
            myBools[0] = new bool[2];
            myBools[1] = new bool[1];
            double[,] myDoubles = new double[2, 2];
            string[] myString = new string[3];

            {
                Console.WriteLine("myInts[0]:{0}, myInts[1]:{1}, myInts[2]:{2}", myInts[0], myInts[1], myInts[2]);
            }


            myBools[0][0] = true;
            myBools[0][1] = false;
            myBools[1][0] = true;
            Console.WriteLine("myBools[0][0]:{0}, myBools[1][0]:{1}", myBools[0][0], myBools[1][0]);

            myDoubles[0, 0] = 3.147;
            myDoubles[0, 1] = 7.157;
            myDoubles[1, 1] = 2.117;
            myDoubles[1, 0] = 56.00138917;
            Console.WriteLine("myDoubles[0,0]:{0}, myDoubles[1, 0]:{1}", myDoubles[0, 0], myDoubles[1, 0]);


            myString[0] = "Andi";
            myString[1] = "Bella";
            myString[2] = "Chelsea";
            Console.WriteLine("myStrings[0]:{0}, myStrings[1]:{1}, myStrings[2]:{2}", myString[0], myString[1], myString[2]);

            Console.ReadKey();


 lalu selesai, klik star dan akan mucul form berwarna hitam seperti berikut:  :)

 

Tidak ada komentar:

Posting Komentar