示例#1
0
         static void Main(string[] args)
         {
             StudentStruct student = new StudentStruct();
             List<StudentStruct> myList = new List<StudentStruct>();
             student.grades = new List<string>();
 
             // get all lines from text file
             string[] allLinesFromFile = File.ReadAllLines(pathSource);
 
             // iterate through each line and process it
             foreach(string line in allLinesFromFile)
             {
             	// split each line on ','
             	string[] sections = line.Split(',');
             	student.studentID = sections[0];
             	student.studentName = sections[1];
 
             	// use this loop to add numbers to list of grades
             	for(int i =2; i < sections.Length; i++)
 				{
 					student.grades.Add(sections[i]);
 				}
 
 				// add this student to list
             	myList.Add(student);
 
             	// create new object of student
             	student = new StudentStruct();
             	student.grades = new List<string>();
             }
         }
示例#2
0
         static void Main(string[] args)
         {
             StudentStruct student = new StudentStruct();
             List<StudentStruct> myList = new List<StudentStruct>();
             student.grades = new List<string>();
 
             string[] allLinesFromFile = File.ReadAllLines(pathSource);
             foreach(string line in allLinesFromFile)
             {
             	string[] sections = line.Split(',');
             	student.studentID = sections[0];
             	student.studentName = sections[1];
 
             	student.grades.Add(sections[2]);
             	student.grades.Add(sections[3]);
             	student.grades.Add(sections[4]);
             	student.grades.Add(sections[5]);
             	student.grades.Add(sections[6]);
             	student.grades.Add(sections[7]);
             	student.grades.Add(sections[8]);
 
             	myList.Add(student);
             	student = new StudentStruct();
             }
         }
示例#3
0
    void ValueRefTest()
    {
        string str1 = "1";       //str1 ---> new string("1")
        string str2 = str1;      //str2 --> str1传递引用

        str2 = "2";              //str2 --> new string("2") 传引用,str2指向一个新的字符串,str1没有改变
        Console.WriteLine(str1); //1
        //但是string又有值传递的效果,这bai是因为string是常量,不能更改

        StudentClass studentClass1 = new StudentClass();

        studentClass1.Age = 1;
        StudentClass studentClass2 = studentClass1;

        studentClass2.Age = 2;
        Console.WriteLine(studentClass1.Age);//2


        StudentStruct studentStruct1 = new StudentStruct();

        studentStruct1.Age = 1;

        StudentStruct studentStruct2 = studentStruct1;

        studentStruct2.Age = 2;
        Console.WriteLine(studentStruct1.Age);//3
    }
        public static void TypeConversion()
        {
            // SAMPLE: Type conversion - implicit
            StudentStruct studentStruct = new StudentStruct("Gandalf", "Grey");
            StudentClass  studentClass  = studentStruct;

            Console.WriteLine("StudentStruct studentStruct = new StudentStruct(\"Gandalf\", \"Grey\");");
            Console.WriteLine("StudentClass studentClass = studentStruct;");
            Console.WriteLine($"studentClass.GetStudentDetails() = {studentClass.GetStudentDetails()}");
        }
示例#5
0
    IEnumerator SendPost(string _url, WWWForm _wForm)
    {
        WWW postData = new WWW(_url, _wForm);

        yield return(postData);

        if (postData.error != null)
        {
            Debug.Log(postData.error);
        }
        else
        {
            Debug.Log(postData.text);

            JsonData data = JsonMapper.ToObject(postData.text);

            StudentStruct structInfo = new StudentStruct();
            structInfo.pageSize         = (int)data["pageSize"];
            structInfo.currentPageIndex = (int)data["currentPageIndex"];
            structInfo.totalRecord      = (int)data["totalRecord"];
            structInfo.totalPage        = (int)data["totalPage"];

            if (data["datas"].IsArray)
            {
                List <StudentInfo> list = new List <StudentInfo>();
                foreach (JsonData datas in data["datas"])
                {
                    //Debug.Log(datas["name"]);
                    StudentInfo info = new StudentInfo();
                    list.Add(info);

                    info.id       = (int)datas["id"];
                    info.name     = (string)datas["name"];
                    info.schoolId = (int)datas["schoolId"];
                    info.gradeId  = (int)datas["gradeId"];
                    info.userName = (string)datas["userName"];
                    info.password = (string)datas["password"];
                }

                structInfo.gradeArr = list;
            }

            if (_callBack != null)
            {
                _callBack(structInfo);
            }
        }
    }
示例#6
0
         static void Main(string[] args)
         {
             StudentStruct student = new StudentStruct();
             List<StudentStruct> myList = new List<StudentStruct>();
             student.grades = new List<string>();
 
             string[] allLinesFromFile = File.ReadAllLines(pathSource);
             foreach(string line in allLinesFromFile)
             {
             	string[] sections = line.Split(',');
             	student.studentID = sections[0];
             	student.studentName = sections[1];
 
             	for(int i =2; i < sections.Length; i++)
 				{
 					student.grades.Add(sections[i]);
 				}
 
             	myList.Add(student);
             	student = new StudentStruct();
             }
         }