나는 이와 같은 간단한 클래스 목록을 가지고 있습니다.txt에서/txt로 클래스 목록 저장 /로드
public class Album
{
public int IDNumber { get; set; }
public string AlbumName { get; set; }
public string Artist { get; set; }
public int ReleaseDate { get; set; }
public int TrackAmount { get; set; }
public string Location { get; set; }
public int Rating { get; set; }
public Album(int _id, string _name, string _artist, int _releasedate, int _trackamount, string _location, int _rating)
{
IDNumber = _id;
AlbumName = _name;
Artist = _artist;
ReleaseDate = _releasedate;
TrackAmount = _trackamount;
Location = _location;
Rating = _rating;
}
}
그리고 파일에 저장하고 파일에서 읽어야합니다. 나는 C++에 상당히 익숙하다. C++의 메서드는 전혀 작동하지 않는다. 이 작업을 수행하는 간단한 방법이 있습니까? 이 파일에 다음과 같이 표시하고 싶습니다.
id albumname artist releasedate trackamout location rating
간단한 방법이 있습니까?
당신이 찾고있는 것은 '직렬화'라는 용어입니다. "클래스/구조체를 직렬화하는"방법에 대해 많은 예제를 온라인에서 찾을 수있을 것이라고 확신합니다. – Kache