Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have wrtten this program that must create a Method named Display in the shirtD

ID: 3669970 • 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; }
                   
           The last answer I recieved for this question was NOT helpful at all. I am getting an error message now that says


Error   CS0555   User-defined operator cannot take an object of the enclosing type and convert to an object of the enclosing type   ShirtDemo   C:C#Module 7ShirtDemoShirtDemo ewShirt.cs   12

        }
    }
}

Explanation / Answer

Shirt.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShirtDemo
{
    class Shirt
    {
        //Instances
        public string material { get; set; }
        public string color { get; set; }
        public string size { get; set; }

        public Shirt()
        {

        }
        public Shirt(string m, string c, string s)
        {
            this.material = m;
            this.color = c;
            this.size = s;
        }

    }
}

ShirtClient.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShirtDemo
{
    class ShirtClient
    {
        static void Main(string[] args)
        {
            Shirt[] array1 = new Shirt[5];
            array1[0] = new Shirt("Cotton", "black", "Large");
            array1[1] = new Shirt("Nylon", "White", "Small" );
            array1[2] = new Shirt("Cotton", "yellow", "medium");
            array1[3] = new Shirt("Nylon", "green", "Large" );
            array1[4] = new Shirt("Cotton", "black", "Medium" );

            DisplayStrings(array1);
        }

        // params array method
        public static void DisplayStrings(params Shirt[] array)
        {
            foreach (Shirt x in array)
            {
                Console.WriteLine("Material is:" + x.material);
                Console.WriteLine("Size is:" + x.size);
                Console.WriteLine("Color is:" + x.color);
                Console.WriteLine("---------------------------------------");
            }
        }
    }
}