snowowl snowowl - 1 month ago 8
C# Question

How to store ISBN in array?

How can I use input ISBN number like this 01316295910 store in an array?And let it print on screen list this : ISBN 0 1 3 1 6 2 9 5 9 10(<=X)

Here is my code :

int[] A = new int[10];
Console.Write("input ISBN:");
for (int i = 0; i < A.Length; i++)
{
A[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("ISBN",A[i]);
}
Console.ReadLine()

Answer

I will suggest this step by step so you can get the logic

//declare the array
int[] A = new int[10];
Console.Write("input ISBN:");

//Read the isbn from the console
string input = Console.ReadLine();
//turn that into a char array
char[] characters = input .ToCharArray();

StringBuilder sb = new StringBuilder();
sb.append("ISBN: ");
//iterate
for (int i = 0; i < characters.Length; i++)
{
    sb.append(characters[i]).append(" "); 
}
//print it
Console.WriteLine(sb);
Comments