What you would want to do would be something like this:
public class Book
{
public string ISBN { get; set; }
public string Title {get; set; }
public string Author {get; set; }
}
The book will represent our data model. Now you would do this:
List<Book> library = new List<Book>();
int quantity;
while(quantity < 7)
{
library.Add("12345", "C#", "Someone");
}
What the code is doing, we create a List<Book>
which will hold our data model. Then you would have a loop that iterates based on value the user inputs. Then you would simply call the library (List) and add after it ask the user for input.
Obviously I'm not attempting to get user input or validation, but is using the example of how to use a List
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…