Create a Class named BooksDemo accepts and displays the details of books using multidimensional array.
BOOKDemo:-
colName: String[4] = {"Book title", "Author", "Publisher", "Price"}
bookDetails: String[2, 4]
____________________
+Main(args: string[])
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace C_SHARP
{
class BooksDemo
{
public String[] colName = { "Book title", "Author", "Publisher", "Price" };
public String[,] bookDetails = new string[2, 4];
static void Main(string[] args)
{
BooksDemo books_demo = new BooksDemo();
for (int d = 0; d < 2; d++)
{
for (int c = 0; c < books_demo.colName.Length; c++)
{
Console.Write("Enter {0}: ", books_demo.colName[c].ToLower());
books_demo.bookDetails[d, c] = Console.ReadLine();
}
Console.WriteLine();
}
for (int d = 0; d < 2; d++)
{
for (int c = 0; c < books_demo.colName.Length; c++)
{
Console.Write("{0}: {1}\n", books_demo.colName[c], books_demo.bookDetails[d, c]);
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Comments
Leave a comment