Click here to Skip to main content
15,895,812 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {
            //What should i do to print list student at here?
        }
    }
     class Student
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Class { get; set; }
        public string Major { get; set; }
    }
     class ListItemhelper
    {
        public static IEnumerable<Student> GetListItemData(int id)
        {
            return new List<Student>
            {
                {new Student{Id=1,LastName="a",FirstName="A",Major="IT",Class="10dthh"}},
                {new Student{Id=2,LastName="b",FirstName="B",Major="IT",Class="10dthh"}}
            };
        }
    }
     class ListStudentPresenter
    {
        private IStudentList student;
        public ListStudentPresenter(IStudentList student)
        {
            this.student = student;
        }
        public void LoadListItem(int id)
        {
            IEnumerable<Student> stus = ListItemhelper.GetListItemData(id);
            if (stus != null && stus.Any())
            {
                student.Istudent = stus;
            }
            else
            {
                student.MessageError = "No items found";
            }
            //view.LoadData();
        }
    }
    public interface IStudentList{
        IEnumerable<Student> Istudent {get;set;}
        string MessageError { get; set; }
      }
}

I'm trying to implement MVP console environment. Then now I wanna display List of students in view to screen but i don't know how. Please help me !!!
Posted
Updated 23-Jul-15 18:41pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Jul-15 1:03am    
Help with what? You are not doing anything resembling MVP, which might be an overkill for a simple console-only application. But yes, you can make it more complex and use MVP architectural pattern, if you really want to. So far, we are not talking about anything material.
—SA

Please see my comment to the question.

I have a strong impression that you don't know what you are talking about and don't know what MVP is. How it can be called "MVP console environment"? Most likely, it's about this architectural pattern:
https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter[^],
https://en.wikipedia.org/wiki/Architectural_pattern[^].

In the question below your title, there is no trace of model, or view, or controller, only a question on how to display some list. What do you mean how. By using System.Console.Write of System.Console.WriteLine for each list element, of course.

More importantly, I'm not sure you understand that any architectural pattern hardly can be your goal. This is something which may or may not help reaching the goals of your project, tool, not a target.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900