IDEA
- User input data
- Convert to index
- Using index number fund element vaule
- Output element vaule
Screenshot
Code
using System;
namespace array2d
{
public class array2d
{
public static void Main(string[] args)
{
//initilizing arrays
string[,] platenumber = new string[5,3] { {"ZJI163","USA1008","PHA101"}, {"PJ130108", "USA1006","JAP118" },
{"MAX168", "USA1002" ,"TWD120"}, { "AZZ9756", "USA1005","KOR119" },
{"NAS1223","USA109","DDT886"}
};
//wait for user input,convert to int
Console.WriteLine("Welcome use DK parking system!\n Solt: 0-4 \n floor: 0-2");
Console.WriteLine("Plz type slot: ");
int solt = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Plz type floor: ");
int floor = Convert.ToInt32(Console.ReadLine());
// decision the length of the element
if (solt < 5 && floor < 3)
{
string car = platenumber[solt, floor];
Console.WriteLine("Found platenumber is :" + car);
}
else
{
Console.WriteLine("\nThe value you entered does not exist");
}
Console.WriteLine("Thank you !");
Console.ReadLine();
}
}
}