return list<>
Written by: maffelu , 2009-04-17 07:19:46
public class Cards
{
public string color;
public int number;
public Cards(string color, int number)
{
this.color = color;
this.number = number;
}
}
public class ListUtils
{
public ListUtils()
{
}
public List<Cards> populateDeck()
{
List<Cards> lst = new List<Cards>();
string[] colors = new string[]{"Hearts", "Spade", "Clove", "Diamond"};
for (int j=0;j <4 ;j++ ) {
for (int i=2;i<15 ;i++ ) {
lst.Add(new Cards(colors[j], i));
}
}
return lst;
}
}
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
void MainFormLoad(object sender, EventArgs e)
{
ListUtils LU = new ListUtils();
List<Cards> myList = LU.populateDeck();
myList.ForEach(delegate(Cards Cs)
{
lsbIndex1.Items.Add(Cs.color + " " + Cs.number);
});
}
}
ListUtils LU = new ListUtils();
List<Cards> myList = LU.populateDeck();
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.