List<uint> possible_numbers = new List<uint>();
Although when I try to compile this code, I get an error that 'List' is undefined. Perhaps I am not including the correct 'using' statements at the start of my code.
List<uint> possible_numbers = new List<uint>();
|
|
|
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
System.Collections.Generic.List<uint> possible_numbers = new System.Collections.Generic.List<uint>();
using System.Collections.Generic;
Microsoft MVP (2012) - My MSDN Profile
~ "The universe is an intelligence test." - Timothy Leary ~
int[]intArray;Fixed length at the time of declaration but not the values
intArray = new int[5];Practical Example of a Dynamic Array
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnADD_Click(object sender, EventArgs e)
{
lstBoxValues.Items.Add(textBox1.Text);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnCreate_Click(object sender, EventArgs e)
{
string[] strListItems;
//the number of items in the list box is the size of our array.
int intNumItems = lstBoxValues.Items.Count;//get the number of items
strListItems = new string[intNumItems];
//use a for iteration to add the items.
//List boxes are also 0 based. The first item in the list will be referred to as lstBoxValues[0].
for (int intX = 0; intX < lstBoxValues.Items.Count; intX++)
strListItems[intX] = lstBoxValues.Items[intX].ToString();
//Show array properties in a rich text box named rtbArrayValues
rtbArrayValues.Text = "Total number of elements = " + strListItems.LongLength + "\n";//the \n is a return
//show all of the values using the for iteration
for (int intX = 0; intX <= strListItems.GetUpperBound(0); intX++)
rtbArrayValues.Text += "value " + intX + " is " + strListItems[intX] + "\n";
}
}
}
Sweta
0 members, 1 guests, 0 anonymous users