32
1
using System;
2
using System.Collections.Generic;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
List<string> Titles = new List<string>(new string[] { "title1", "title2", "title3" });
9
List<Book> Books = new List<Book>(Titles.Count);
10
for (int i = 0; i < Titles.Count; i++)
11
{
12
Books.Add(new Book(Titles[i], string.Empty));
13
}
14
15
Console.WriteLine(Books[0].Title);
16
}
17
}
18
19
public class Book
20
{
21
private string mTitle;
22
public string Title { get { return mTitle; } }
23
24
private string mAuthor;
25
public string Author { get { return mAuthor; } }
26
27
public Book(string _title, string _author)
28
{
29
this.mTitle = _title;
30
this.mAuthor = _author;
31
}
32
}
Cached Result