# Full Code Array, SwitchCase

Latihan Array Multidimensi
unknown
plain_text
7 months ago
3.0 kB
1
Indexable
Never
```using System;

namespace ARRAYMULTIDIMENSI
{
class ARRAYMHS
{
public static void Main(string[] args)
{
//initializing 2D array
char ch;
string[ , ] x = new string[4,2];
// Input Kolom nama 1
Console.Write("Input nama ke 1 : ");
//Input Kolom NIM 1
Console.Write("Input NIM ke 1 : ");
// Input Kolom nama 2
Console.Write("Input nama ke 2 : ");
//Input Kolom NIM 1
Console.Write("Input NIM ke 2 : ");
// Input Kolom nama 3
Console.Write("Input nama ke 3 : ");
//Input Kolom NIM 3
Console.Write("Input NIM ke 3 : ");
// Input Kolom nama 4
Console.Write("Input nama ke 4 : ");
//Input Kolom NIM 4
Console.Write("Input NIM ke 4 : ");
// access first element from second row
Console.WriteLine("=====================================");
Console.WriteLine("PILIH TAMPILAN");
//Console.WriteLine("a. Input data");
Console.WriteLine("a. Tampilkan Seluruh Kolom Nama");
Console.WriteLine("b. Tampilkan Seluruh Kolom NIM");
Console.WriteLine("c. Tampilkan Seluruh Kolom Tabel");
Console.Write("Masukkan pilihan     : ");

switch(Char.ToLower(ch))
{
case 'a':
Console.WriteLine("NAMA");
Console.WriteLine("=================================");
Console.WriteLine("Nama ke 1 " + x[0,0]);
Console.WriteLine("Nama ke 2 " + x[1,0]);
Console.WriteLine("Nama ke 3 " + x[2,0]);
Console.WriteLine("Nama Ke 4 " + x[3,0]);
break;
case 'b':
Console.WriteLine("NIM");
Console.WriteLine("=================================");
Console.WriteLine("Nim ke 1 " + x[0,1]);
Console.WriteLine("Nim ke 2 " + x[1,1]);
Console.WriteLine("Nim ke 3 " + x[2,1]);
Console.WriteLine("NIm ke 4 " + x[3,1]);
break;
case 'c':
Console.WriteLine("Tabel");
Console.WriteLine("=================================");
Console.WriteLine("Nama: " + x[0,0] + " | " + "Nim: " + x[0,1]);
Console.WriteLine("Nama: " + x[1,0] + " | " + "Nim: " + x[1,1]);
Console.WriteLine("Nama: " + x[2,0] + " | " + "Nim: " + x[2,1]);
Console.WriteLine("Nama: " + x[3,0] + " | " + "Nim: " + x[3,1]);
break;
default:
Console.WriteLine("pilihan tidak tersedia");
break;
}
}
}
}```