Answer:
//Shirt.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ShirtApplication
{
class Shirt
{
public string Material { get; set; }
public string Color { get; set; }
public string Size { get; set; }
public Shirt()
{
Material = "";
Color = "";
Size = "";
}
public Shirt(string material, string color, string size)
{
this.Material = material;
this.Color = color;
this.Size = size;
}
}
}
//Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ShirtApplication
{
class Program
{
static void Main(string[] args)
{
Shirt shirt = new Shirt("cotton", "white", "L");
Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color","Size");
display(shirt);
shirt = new Shirt("cotton", "blue", "XL");
display(shirt);
shirt = new Shirt("polyester", "pink", "M");
display(shirt);
Console.WriteLine();
Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color", "Size");
shirt = new Shirt("cotton", "white", "L");
display(shirt);
shirt = new Shirt("cotton", "blue", "XL");
display(shirt);
shirt = new Shirt("polyester", "pink", "M");
display(shirt);
shirt = new Shirt("silk", "yellow", "S");
display(shirt);
Console.WriteLine();
Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color", "Size");
//Create an instance of Shirt
shirt = new Shirt("cotton", "white", "L");
//call display method
display(shirt);
//Create an instance of Shirt
shirt = new Shirt("cotton", "blue", "XL");
//call display method
display(shirt);
shirt = new Shirt("polyester", "pink", "M");
//call display method
display(shirt);
//Create an instance of Shirt
shirt = new Shirt("silk", "yellow", "S");
display(shirt);
shirt = new Shirt("silk", "white", "XXL");
//call display method
display(shirt);
Console.ReadKey();
}
public static void display(Shirt shirt)
{
Console.WriteLine("{0,12}{1,10}{2,10}", shirt.Material, shirt.Color, shirt.Size);
}
}
}
Explanation:
- In the program.cs file, create an instance of Shirt
.
- Call the display method with relevant values.
- Define a method to display that takes Shirt object and prints the properties of shirt object to console
.