Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active April 8, 2016 23:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save conanak99/6962826061b45f88bc2d4759fcfe70f1 to your computer and use it in GitHub Desktop.
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