A constructor is called when you create a new instance of a class.
File: Quote.cs
using System;
using System.Collections.Generic;
public class Quote
{
private List<string> _quotes = new List<string>();
public string GetQuote()
{
Random rnd = new Random();
return _quotes[rnd.Next(_quotes.Count)];
}
public Quote()
{
_quotes.Add("A");
_quotes.Add("B");
_quotes.Add("C");
}
}
|