🔒 Closed C#(List) pa help naman po.SOLVED

Status
Not open for further replies.
Xlayer mrHazan waaah. Patulong naman po. Kung ano mali at anong dapat idagdag. Salamat po.
 

Attachments

  • Screenshot_20201108_173657_com.radinc.csharpshell.webp
    Screenshot_20201108_173657_com.radinc.csharpshell.webp
    54.5 KB · Views: 9
[XX='1nn0c3ntv5, c: 474930, m: 1664641'][/XX] ex po ng convert halimbawa eenter po ang user ng 0 ang lalabas po dun ay X. Ayan po yung example output.

Ayan po. Nasa taas ng pic.
 

Attachments

  • Screenshot_20201107_144549.jpg
    Screenshot_20201107_144549.jpg
    53 KB · Views: 1
Medyo kulang mga binibigay mong information samin, 0-9 lang ba ang i-input? pwede ba more than once mag input ng nailagay na number? Bakit sa example naka remove ang index 2 (O) pero nung nag convert nandun pa din si O.
 
Medyo kulang mga binibigay mong information samin, 0-9 lang ba ang i-input? pwede ba more than once mag input ng nailagay na number? Bakit sa example naka remove ang index 2 (O) pero nung nag convert nandun pa din si O.
Hindi po ireremove you zero(0) yung yung number po sa baba ang tawag po dun is index and then yung nasa taas naman po na words ang tawag po dun is element.
 
M yung tinanggal niya since

nag input siya ng 1, 2, at 3 (C,O, at M) na ang index niya sa list ay 0,1, at 2
kaya nung ininput niya ay 2 sa Remove an Element nawala ang M kaya naging C at O ang output nung nag convert siya
 
May mas simple at matino pang code dito, intay intay ka baka may tumulong pa sa'yo.

Code:
static void Main(string[] args)
        {
            List<string> myList = new List<string>();
            string[] letters = { "X", "C", "O", "M", "P", "U", "T", "E", "R", "S" };
            //0-1-2-3-4-5-6-7-8-9

            Console.WriteLine("=o=o=o=MENU=o=o=o=");
            Console.WriteLine("[1] - ADD AN ELEMENT");
            Console.WriteLine("[2] - REMOVE AN ELEMENT");
            Console.WriteLine("[3] - CONVERT");
            Console.WriteLine("[4] - EXIT");

            while (true)
            {
                Console.Write("\nENTER YOUR CHOICE: ");
                int choice = Convert.ToInt32(Console.ReadLine());

                if (choice > 4)
                {
                    Console.WriteLine("PLEASE ENTER A VALID CHOICE");
                }

                else
                {
                    //ADD AN ELEMENT // CHOICE 1
                    if (choice == 1)
                    {
                        Console.Write("\nINPUT A NUMBER: ");
                        int elementalChoice = Convert.ToInt32(Console.ReadLine());
                        myList.Add(letters[elementalChoice]);
                        //foreach (var displayRequirement in myList)
                        //{
                        //    Console.Write("ELEMENT: "+displayRequirement+"\n");
                        //}
                    }

                    //REMOVE AN ELEMENT // CHOICE 2
                    else if (choice == 2)
                    {
                        int currentIndexNumbers = myList.Count();
                        if (currentIndexNumbers == 0)
                        {
                            currentIndexNumbers = 0;
                        }
                        else
                        {
                            currentIndexNumbers = currentIndexNumbers - 1;
                        
                        }
                        Console.WriteLine("SELECT AN INDEX BETWEEN 0 AND " + currentIndexNumbers+": ");
                        int removeIndex = Convert.ToInt32(Console.ReadLine());
                        myList.RemoveAt(removeIndex);
                        //foreach (var displayRequirement in myList)
                        //{
                        //    Console.Write("ELEMENT: " + displayRequirement + "\n");
                        //}
                    }

                    //CONVERT
                    else if (choice == 3)
                    {
                    
                         //Ikaw na dito haha

                    }

                    else
                    {
                        break;
                    }


                }

            }

        }
 
Status
Not open for further replies.

About this Thread

  • 54
    Replies
  • 1K
    Views
  • 5
    Participants
Last reply from:
Novuz33

Online now

Members online
649
Guests online
2,488
Total visitors
3,137

Forum statistics

Threads
2,276,484
Posts
28,970,361
Members
1,231,301
Latest member
cksmsmari21
Back
Top