CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> Titles = new List<string>(new string[] { "title1", "title2", "title3" });
List<Book> Books = new List<Book>(Titles.Count);
for (int i = 0; i < Titles.Count; i++)
{
Books.Add(new Book(Titles[i], string.Empty));
}
Console.WriteLine(Books[0].Title);
}
}
public class Book
{
private string mTitle;
public string Title { get { return mTitle; } }
private string mAuthor;
public string Author { get { return mAuthor; } }
public Book(string _title, string _author)
{
this.mTitle = _title;
this.mAuthor = _author;
}
}