I have wrtten this program that must create a Method named Display in the shirtD
ID: 3669945 • Letter: I
Question
I have wrtten this program that must
create a Method named Display in the shirtDemo class that takes a variable number of arguments using a parameter array.
Loop through the parameter array displaying the properties from each shirt object in the array.
Call the Display method a few times using a different number of shirt objects each time to verify that the method handles them properly.
When I try to run the program is just gets hung up can you help me figure out where the issue is?
static void Main(string[] args)
{
Shirt[] Shirt = new Shirt[3];
Shirt[0].Material = "Cotton";
Shirt[1].Material = "Polyester";
Shirt[2].Material = "Silk";
Shirt[0].Color = "Blue";
Shirt[1].Color = "Red";
Shirt[2].Color = "Pink";
Shirt[0].Size = "Small";
Shirt[1].Size = "Medium";
Shirt[2].Size = "Large";
}
internal void DisplayShirts(params Shirt[] shirts)
{
foreach (Shirt shirt in shirts)
{
Console.WriteLine("{0} -{1} - {2}", newShirt.Material, newShirt.Color, newShirt.Size);
Console.ReadLine();
}
}
class ShirtDemo
{
public string Material { get; set; }
public string Color { get; set; }
public string Size { get; set; }
}
}
}
Explanation / Answer
1) In public void main it should be String[]. you have written strin[].
2) defining a function name:always it should start with small letters followed by capital letters
3) i think you should invoke the functions rather than directly using get and set. Try it in different way.