Professional Documents
Culture Documents
Author.cs
using System;
namespace Author
this.Name = Name;
this.Email = Email;
this.Gender = Gender;
public Author()
{
if (Gender=='M' || Gender =='m')
Console.WriteLine("Author's Name: \t" + Name + "\n" + "Author's Email: \t" + Email + "\n"
+"Author's Gender: \tMale");
Console.WriteLine("Author's Name: \t" + Name + "\n" + "Author's Email: \t" + Email + "/n" +
else
Book.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Author
this.BookId = BookId;
this.BookName = BookName;
BookAuthor.DisplayAuthor();
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Author
class Program
aAuthor.DisplayAuthor();
aBook.BookAuthor = aAuthor;
aBook.setBookName("Inferno", "UI93442KJ");
aBook.getBook();
Console.ReadKey();
}
Problem 2
Programs.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2NumberSwapConsoleApp
class Program
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("After swapping first number {0} and second number {1}", a,b);
Console.WriteLine("Before swapping first number {0} and second number {1}", num1,
num2);
Swap(num1,num2);
Console.ReadKey();
Problem 3
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2DArrayMatrixConsoleApp
class Program
try
{
ary[i, j] = Convert.ToInt32(Console.ReadLine());
Console.Write(ary[i, j] + "\t");
Console.WriteLine();
{
for (int j = 0; j < 3; j++)
catch (Exception)
}
Console.ReadKey();
Problem 4
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PatternNumberConsoleApp
class Program
numbers[i, j] = Convert.ToInt32(Console.ReadLine());
Console.Write(rowSum);
Console.WriteLine();
rowSum = 0;
}
for (j = 0; j <= 2; j++)
columnSum = 0;
Console.WriteLine();
if (i == j)
Console.Write(numbers[i, j]);
else
{
Console.Write(" ");
Console.WriteLine();
//Console.Write(diagonalSum);
Console.ReadKey();