How to properly display the name of the student with degree in mobile only in a private Dictionary<string, string>

How to properly display the name of the student with degree in mobile only in a private Dictionary<string, string> _studentDegree = new Dictionary<string, string>();

I’m having a hard time coming with a way to just show mobile student. Hours staring at the screen with blank ideas.

// This method work perfectly
private void ShowAllStudents()
        {
            Console.Clear();
            //Setting UI color
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Show All Students: ");
            Console.WriteLine("==================");
            Console.WriteLine("==================");
            Console.ForegroundColor = ConsoleColor.Gray;
            Student myStudent = new Student();


            int counter = 0;
            Console.WriteLine($"{"  "} {"Name", -15} {"Degree", -10}");
            foreach (KeyValuePair<string, string> kvp in _studentDegree)
            {

                counter++;
                Console.WriteLine($"{counter}. {kvp.Key, -15} {kvp.Value, -10}");
                //myStudent.GenerateGrade();
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            _myMenu.Display();
            Selection();
        }

// Output: 
Show All Students: 

   Name            Degree    
1. JEAN            MOBILE    
2. MAX             WEB       
3. LU              MOBILE    
4. TOM             WEB       

Press any key to continue...


//End of method



// Only display mobile student

private void ShowMobileStudents()
        {
            Console.Clear();
            //Setting UI color
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Show Mobile Students: ");
            Console.WriteLine("=====================");
            Console.WriteLine("=====================");
            Console.ForegroundColor = ConsoleColor.Gray;



            
            
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            _myMenu.Display();
            Selection();
        }

so… an if-statement?

also you probably want to replace this

with var

1 Like

By the way either one works. Thanks!

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.