-
-
Save tuannguyenssu/402268af9cc16be98a24cb6aaf24341f to your computer and use it in GitHub Desktop.
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
// Student bây giờ chỉ chứa các thông tin | |
public class Student | |
{ | |
public string Name { get; set;} | |
public int Age { get; set;} | |
} | |
// Class này chỉ format thông tin hiển thị student | |
public class Formatter | |
{ | |
public string FormatText(Student std) | |
{ | |
return "Name: " + std.Name + ". Age: " + std.Age; | |
} | |
public string FormatJson(Student std) | |
{ | |
return Json.Serialize(std); | |
} | |
} | |
// Class này chỉ lo việc lưu trữ | |
public class Store | |
{ | |
public void SaveToDatabase(Student std) | |
{ | |
dbContext.Save(std); | |
} | |
public void SaveToFile(Student std) | |
{ | |
Files.Save(std, "fileName.txt"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment