【发布时间】:2021-12-29 02:06:05
【问题描述】:
我有一些 JSON 文件和结构。在静态 void Initialization() 中,我想将 json 文件中的信息放入 Data[i]。我该怎么做?
private static Student[] Data = new Student[99];
struct Student
{
public int Id;
public string FullName;
public DateTime BirthdayDate;
public string Institute;
public string Group;
public string Course;
public double AvgMark;
public string form_ed;
public string lvl_ed;
public int zadolzh;
public Student(int Id, string FullName, DateTime BirthdayDate, string Institute, string Group, string Course, double AvgMark, string form_ed, string lvl_ed, int zadolzh)
{
this.Id = Id;
this.FullName = FullName;
this.BirthdayDate = BirthdayDate;
this.Institute = Institute;
this.Group = Group;
this.Course = Course;
this.AvgMark = AvgMark;
this.form_ed = form_ed;
this.lvl_ed = lvl_ed;
this.zadolzh = zadolzh;
}
}
static void Initialization()
{
}
【问题讨论】:
-
Json.NET 将是最简单的方法
-
这里使用类而不是结构会更传统。
-
在你的初始化方法中,循环你的json文件,反序列化每个文件并将返回的学生对象放入学生数组中。
-
请显示你的json
标签: c# json database structure