This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
public string Name { get; set;} | |
public int Age { get; set;} | |
// Format class này dưới dạng text, html, json để in ra | |
public string GetStudentInfoText() { | |
return "Name: " + Name + ". Age: " + Age; | |
} | |
public string GetStudentInfoHTML() { | |
return "<span>" + Name + " " + Age + "</span>"; | |
} | |
public string GetStudentInfoJson() { | |
return Json.Serialize(this); | |
} | |
// Lưu trữ xuống database, xuống file | |
public void SaveToDatabase() { | |
dbContext.Save(this); | |
} | |
public void SaveToFile() { | |
Files.Save(this, "fileName.txt"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment