【发布时间】:2021-12-27 17:16:02
【问题描述】:
我在下面有一个 Student 类,我在 ViewModel 类中使用 ObservableCollection 在 ListView 中显示学生。我是否可以从 csv/电子表格中读取数据来填充 ObservableCollection 的学生?
public class Student
{
public string Firstname { get; set; }
public string Surname { get; set; }
public string Module { get; set; }
public Project(string Firstname, string Surname, string Module)
{
this.Firstname = Firstname;
this.Surname = Surname;
this.Module = Module;
}
public class ProjectListViewModel
{
public ObservableCollection<Student> Students { get; set; }
public ProjectListViewModel()
{
Students = new ObservableCollection<Project>();
Students.Add(new Student("Ben", "Ledley", "Maths"));
Students.Add(new Student("John", "Alex", "English"));
Students.Add(new Student("Sam", "Craig", "Biology"));
}
}
【问题讨论】:
标签: c# csv xamarin xamarin.forms spreadsheet