本文整理汇总了C#中System.Collections.ArrayList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.ArrayList.Add方法的具体用法?C# System.Collections.ArrayList.Add怎么用?C# System.Collections.ArrayList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了System.Collections.ArrayList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
int totalCount;
System.Collections.ArrayList list =
new System.Collections.ArrayList();
Console.Write("Enter a number between 2 and 1000:");
totalCount = int.Parse(Console.ReadLine());
// Execution-time error:
// list.Add(0); // Cast to double or 'D' suffix required.
// Whether cast or using 'D' suffix,
// CIL is identical.
list.Add((double)0);
list.Add((double)1);
for(int count = 2; count < totalCount; count++)
{
list.Add(
((double)list[count - 1] +
(double)list[count - 2]));
}
foreach(double count in list)
{
Console.Write("{0}, ", count);
}
}
示例2: GeneratePoints
public override System.Collections.ArrayList GeneratePoints(EPoint ptStart)
{
//Calculate curve's control and end anchor points:
//Control point is the start point + offset to control
EPoint ptControl = ptStart + this._ptControl;
//End point is control point + offset to anchor:
EPoint ptAnchor = ptControl + this._ptAnchor;
//now calculate two bezier handles for the curve (Flash uses quadratic beziers, GDI+ uses cubic).
//The two handles are 2/3rds from each endpoint to the control point.
EPointF diff = (ptControl-ptStart).ToEPointF();
EPointF ctrl1 = EPointF.FromLengthAndAngle(diff.Length*2/3, diff.Angle) + ptStart.ToEPointF();
//EPointF ctrl1 = ptStart.ToEPointF() + diff/2f;
//EPointF ctrl1 = new EPointF(ptStart.X + (1f * (ptControl.X - ptStart.X) / 2f), ptStart.Y + (1f * (ptControl.Y - ptStart.Y) / 2f));
diff = (ptControl-ptAnchor).ToEPointF();
EPointF ctrl2 = EPointF.FromLengthAndAngle(diff.Length*2/3, diff.Angle) + ptAnchor.ToEPointF();
//diff = (ptAnchor-ptControl).ToEPointF();
//EPointF ctrl2 = ptControl.ToEPointF() + diff/2f;
//ctrl2 = new EPointF(ptControl.X + (1f * (ptAnchor.X - ptControl.X) / 2f), ptControl.Y + (1f * (ptAnchor.Y - ptControl.Y) / 2f));
System.Collections.ArrayList pts = new System.Collections.ArrayList();
pts.Add(ptStart.ToEPointF());
pts.Add(ctrl1);
pts.Add(ctrl2);
pts.Add(ptAnchor.ToEPointF());
return pts;
}
示例3: btnCast_Click
private void btnCast_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
System.Collections.ArrayList TestCast = new System.Collections.ArrayList();
TestCast.Add("Test1");
TestCast.Add("Test2");
TestCast.Add("Test3");
IEnumerable<string> query =
TestCast.Cast<string>().OrderBy(n => n).Select(n => n);
foreach (var n in query)
{
listBox1.Items.Add("Cast : " + n);
}
int[] numbers = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
var textNums = from n in numbers
select strings[n];
foreach (var n in textNums)
{
listBox1.Items.Add("Select : " + n);
}
}
示例4: Main
static void Main(string[] args)
{
Toy doll = new Toy();
doll.Make = "rubber";
doll.Model = "barbie";
doll.Name = "Elsa";
Toy car = new Toy();
car.Make = "plastic";
car.Model = "BMW";
car.Name = "SPUR";
System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
myArrayList.Add(doll);
myArrayList.Add(car);
System.Collections.Specialized.ListDictionary myDictionary
= new System.Collections.Specialized.ListDictionary();
myDictionary.Add(doll.Name, doll);
myDictionary.Add(car.Name, car);
foreach (object o in myArrayList)
{
Console.WriteLine(((Toy)o).Name);
}
Console.WriteLine(((Toy)myDictionary["Elsa"]).Model);
Console.ReadLine();
}
示例5: FormatMailToCommand
/// <summary>
///
/// </summary>
/// <param name="p_To">null if not used</param>
/// <param name="p_Cc">null if not used</param>
/// <param name="p_Bcc">null if not used</param>
/// <param name="p_Subject">null if not used</param>
/// <param name="p_Body">null if not used</param>
/// <returns></returns>
public static string FormatMailToCommand(string[] p_To, string[] p_Cc, string[] p_Bcc, string p_Subject, string p_Body)
{
string l_To = FormatEMailAddress(p_To);
string l_CC = FormatEMailAddress(p_Cc);
string l_Bcc = FormatEMailAddress(p_Bcc);
string l_Command = "mailto:";
if (l_To!=null)
l_Command+=l_To;
System.Collections.ArrayList l_Parameters = new System.Collections.ArrayList();
if (l_CC!=null)
l_Parameters.Add("CC="+l_CC);
if (l_Bcc!=null)
l_Parameters.Add("BCC="+l_Bcc);
if (p_Subject!=null)
l_Parameters.Add("subject="+p_Subject);
if (p_Body!=null)
l_Parameters.Add("body="+p_Body);
if (l_Parameters.Count>0)
{
string[] l_tmp = new string[l_Parameters.Count];
l_Parameters.CopyTo(l_tmp,0);
l_Command+="?";
l_Command+=string.Join("&",l_tmp);
}
return l_Command;
}
示例6: summaryInit
public void summaryInit()
{
//*** cb***
//Refer C:\Users\suandich\Downloads\DragAndDropListView_demo\Form1.cs
SummaryMainClass sm = new SummaryMainClass();
DataTable dtRaw = sm.RawData();
for (int i = 0; i < dtRaw.Columns.Count; i++)
{
System.Diagnostics.Debug.Write(sm.dt.Columns[i].ToString() + " | ");
listView1.Items.Add(sm.dt.Columns[i].ToString());
}
string[] Rowfield = new string[listView3.Items.Count];
listView3.Items.CopyTo(Rowfield, 0);
string[] Columnfield = new string[listView2.Items.Count];
listView2.Items.CopyTo(Columnfield, 0);
string[] Datafield = new string[listView4.Items.Count];
listView4.Items.CopyTo(Datafield, 0);
System.Collections.ArrayList list = new System.Collections.ArrayList();
list.Add("Cat");
list.Add("Zebra");
list.Add("Dog");
list.Add("Cow");
DataTable dtSum = sm.SummaryData("",Rowfield,Columnfield);
dataGridView1.DataSource = dtSum.DefaultView;
}
示例7: MultiFormatOneDReader
public MultiFormatOneDReader(System.Collections.Hashtable hints)
{
System.Collections.ArrayList possibleFormats = hints == null ? null : (System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
readers = new System.Collections.ArrayList();
if (possibleFormats != null) {
if (possibleFormats.Contains(BarcodeFormat.EAN_13) ||
possibleFormats.Contains(BarcodeFormat.UPC_A) ||
possibleFormats.Contains(BarcodeFormat.EAN_8) ||
possibleFormats.Contains(BarcodeFormat.UPC_E))
{
readers.Add(new MultiFormatUPCEANReader(hints));
}
if (possibleFormats.Contains(BarcodeFormat.CODE_39)) {
readers.Add(new Code39Reader());
}
if (possibleFormats.Contains(BarcodeFormat.CODE_128))
{
readers.Add(new Code128Reader());
}
if (possibleFormats.Contains(BarcodeFormat.ITF))
{
readers.Add(new ITFReader());
}
}
if (readers.Count==0) {
readers.Contains(new MultiFormatUPCEANReader(hints));
readers.Contains(new Code39Reader());
readers.Contains(new Code128Reader());
// TODO: Add ITFReader once it is validated as production ready, and tested for performance.
//readers.addElement(new ITFReader());
}
}
示例8: GeneratePoints
public override System.Collections.ArrayList GeneratePoints(EPoint ptStart)
{
System.Collections.ArrayList pts = new System.Collections.ArrayList();
EPoint ptEnd = ptStart + this._ptTarget;
pts.Add(ptStart);
pts.Add(ptEnd);
return pts;
}
示例9: AdaptiveLookback
public AdaptiveLookback(Bars bars, int howManySwings, bool UseAll, string description)
: base(bars, description)
{
this.bars = bars;
bool SwingLo, SwingHi;
double lastSL = bars.Low[1];
double lastSH = bars.High[1];
int firstSwingBarOnChart = 0;
int lastSwingInCalc = 0;
int swingCount = 0;
DataSeries so = new DataSeries(bars.Close, "swing_oscillator");
System.Collections.ArrayList SwingBarArray = new System.Collections.ArrayList();
for (int bar = 5; bar < bars.Count; bar++)
{
SwingLo = (CumDown.Series(bars.Low, 1)[bar - 2] >= 2) &&
(CumUp.Series(bars.High, 1)[bar] == 2);
SwingHi = (CumUp.Series(bars.High, 1)[bar - 2] >= 2) &&
(CumDown.Series(bars.Low, 1)[bar] == 2);
if (SwingLo)
so[bar] = -1;
else
if (SwingHi)
so[bar] = 1;
else
so[bar] = 0;
if ((so[bar] != 0) & (swingCount == 0))
{
firstSwingBarOnChart = bar;
swingCount++;
SwingBarArray.Add(bar);
}
else
if (swingCount > 0)
{
if (so[bar] != 0.0)
{
swingCount++;
SwingBarArray.Add(bar);
}
// 20090127 Added
if (swingCount == howManySwings)
base.FirstValidValue = bar;
}
lastSwingInCalc = (SwingBarArray.Count - howManySwings);
if (lastSwingInCalc >= 0)
{
base[bar] = UseAll ? (int)(bars.Count / SwingBarArray.Count) :
(bar - (int)SwingBarArray[lastSwingInCalc]) / howManySwings;
}
}
}
示例10: GetAvailableDestinationTables
private string[] GetAvailableDestinationTables()
{
System.Collections.ArrayList result = new System.Collections.ArrayList();
result.Add("New table");
foreach (Altaxo.Data.DataTable table in Current.Project.DataTableCollection)
result.Add(table.Name);
return (string[])result.ToArray(typeof(string));
}
示例11: cmdSaveAll_Click
private void cmdSaveAll_Click(object sender, EventArgs e)
{
if (!System.IO.File.Exists(txtFile.Text))
{
MessageBox.Show("File is not exist.");
return;
}
System.Collections.ArrayList suffixs = new System.Collections.ArrayList();
suffixs.Add("");
if (chkFlip.Checked) suffixs.Add("f");
if (this.chkSel.Checked) suffixs.Add("s");
if (chkFlip.Checked && chkSel.Checked) suffixs.Add("sf");
System.IO.FileInfo fi = new System.IO.FileInfo(txtFile.Text);
System.IO.FileInfo[] fis = fi.Directory.GetFiles("*.bmp", System.IO.SearchOption.TopDirectoryOnly);
string ext = "";
System.Drawing.Imaging.ImageFormat imgFormat = null;
if (optGif.Checked)
{
ext = "gif";
imgFormat = System.Drawing.Imaging.ImageFormat.Gif;
}
else if (optPng.Checked)
{
ext = "png";
imgFormat = System.Drawing.Imaging.ImageFormat.Png;
}
foreach (System.IO.FileInfo fi2 in fis)
{
foreach (string suffix in suffixs)
{
Bitmap bmp = null;
if (suffix == "f")
bmp = ConvertBitmap(fi2.FullName, true, false);
else if (suffix == "s")
bmp = ConvertBitmap(fi2.FullName, false, true);
else if (suffix == "sf")
bmp = ConvertBitmap(fi2.FullName, true, true);
else
bmp = ConvertBitmap(fi2.FullName, false, false);
string fileName = string.Format(@"{0}\{1}{2}.{3}", fi2.DirectoryName,
fi2.Name.Substring(0, fi2.Name.Length - fi2.Extension.Length),
suffix, ext);
if (System.IO.File.Exists(fileName)) System.IO.File.Delete(fileName);
bmp.Save(fileName, imgFormat);
}
}
MessageBox.Show("Done");
}
示例12: makeAll
/// <summary> <p>Creates skeletal source code (without correct data structure but no business
/// logic) for all data types found in the normative database. For versions > 2.2, Primitive data types
/// are not generated, because they are coded manually (as of HAPI 0.3).
/// </summary>
public static void makeAll(System.String baseDirectory, System.String version)
{
//make base directory
if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
{
baseDirectory = baseDirectory + "/";
}
System.IO.FileInfo targetDir = NuGenSourceGenerator.makeDirectory(baseDirectory + NuGenSourceGenerator.getVersionPackagePath(version) + "datatype");
//get list of data types
System.Collections.ArrayList types = new System.Collections.ArrayList();
System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;
System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
//get normal data types ...
System.Data.OleDb.OleDbCommand temp_OleDbCommand;
temp_OleDbCommand = stmt;
temp_OleDbCommand.CommandText = "select data_type_code from HL7DataTypes, HL7Versions where HL7Versions.version_id = HL7DataTypes.version_id and HL7Versions.hl7_version = '" + version + "'";
System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
while (rs.Read())
{
types.Add(System.Convert.ToString(rs[1 - 1]));
}
//get CF, CK, CM, CN, CQ sub-types ...
System.Data.OleDb.OleDbCommand temp_OleDbCommand2;
temp_OleDbCommand2 = stmt;
temp_OleDbCommand2.CommandText = "select data_structure from HL7DataStructures, HL7Versions where (" + "data_type_code = 'CF' or " + "data_type_code = 'CK' or " + "data_type_code = 'CM' or " + "data_type_code = 'CN' or " + "data_type_code = 'CQ') and " + "HL7Versions.version_id = HL7DataStructures.version_id and HL7Versions.hl7_version = '" + version + "'";
rs = temp_OleDbCommand2.ExecuteReader();
while (rs.Read())
{
types.Add(System.Convert.ToString(rs[1 - 1]));
}
NuGenNormativeDatabase.Instance.returnConnection(conn);
System.Console.Out.WriteLine("Generating " + types.Count + " datatypes for version " + version);
if (types.Count == 0)
{
}
for (int i = 0; i < types.Count; i++)
{
try
{
make(targetDir, (System.String) types[i], version);
}
catch (DataTypeException)
{
}
catch (System.Exception)
{
}
}
}
示例13: StartUIACacheRequestCommand
public StartUIACacheRequestCommand()
{
System.Collections.ArrayList defaultPropertiesList =
new System.Collections.ArrayList();
defaultPropertiesList.Add("Name");
defaultPropertiesList.Add("AutomationId");
defaultPropertiesList.Add("ClassName");
defaultPropertiesList.Add("ControlType");
defaultPropertiesList.Add("NativeWindowHandle");
defaultPropertiesList.Add("BoundingRectangle");
defaultPropertiesList.Add("ClickablePoint");
defaultPropertiesList.Add("IsEnabled");
defaultPropertiesList.Add("IsOffscreen");
this.Property = (string[])defaultPropertiesList.ToArray(typeof(string));
System.Collections.ArrayList defaultPatternsList =
new System.Collections.ArrayList();
defaultPatternsList.Add("ExpandCollapsePattern");
defaultPatternsList.Add("InvokePattern");
defaultPatternsList.Add("ScrollItemPattern");
defaultPatternsList.Add("SelectionItemPattern");
defaultPatternsList.Add("SelectionPattern");
defaultPatternsList.Add("TextPattern");
defaultPatternsList.Add("TogglePattern");
defaultPatternsList.Add("ValuePattern");
this.Pattern = (string[])defaultPatternsList.ToArray(typeof(string));
this.Scope = "SUBTREE";
this.Filter = "RAW";
}
示例14: Test2
/// <exception cref="System.Exception"></exception>
public virtual void Test2()
{
string baseName = GetBaseName();
NeoDatis.Odb.ODB odb = Open(baseName);
long nbFunctions = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
(typeof(NeoDatis.Odb.Test.VO.Login.Function)));
long nbProfiles = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
(typeof(NeoDatis.Odb.Test.VO.Login.Profile)));
NeoDatis.Odb.Test.VO.Login.Function function1 = new NeoDatis.Odb.Test.VO.Login.Function
("function1");
NeoDatis.Odb.Test.VO.Login.Function function2 = new NeoDatis.Odb.Test.VO.Login.Function
("function2");
NeoDatis.Odb.Test.VO.Login.Function function3 = new NeoDatis.Odb.Test.VO.Login.Function
("function3");
System.Collections.IList functions = new System.Collections.ArrayList();
functions.Add(function1);
functions.Add(function2);
functions.Add(function3);
NeoDatis.Odb.Test.VO.Login.Profile profile1 = new NeoDatis.Odb.Test.VO.Login.Profile
("profile1", functions);
NeoDatis.Odb.Test.VO.Login.Profile profile2 = new NeoDatis.Odb.Test.VO.Login.Profile
("profile2", function1);
odb.Store(profile1);
odb.Store(profile2);
odb.Close();
odb = Open(baseName);
// checks functions
NeoDatis.Odb.Objects lfunctions = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
), true);
AssertEquals(nbFunctions + 3, lfunctions.Count);
NeoDatis.Odb.Objects l = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
(typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
.Equal("name", "function2")));
NeoDatis.Odb.Test.VO.Login.Function function = (NeoDatis.Odb.Test.VO.Login.Function
)l.GetFirst();
odb.Delete(function);
odb.Close();
odb = Open(baseName);
AssertEquals(nbFunctions + 2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
(typeof(NeoDatis.Odb.Test.VO.Login.Function))));
NeoDatis.Odb.Objects l2 = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function
), true);
// check Profile 1
NeoDatis.Odb.Objects lprofile = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
(typeof(NeoDatis.Odb.Test.VO.Login.Profile), NeoDatis.Odb.Core.Query.Criteria.Where
.Equal("name", "profile1")));
NeoDatis.Odb.Test.VO.Login.Profile p1 = (NeoDatis.Odb.Test.VO.Login.Profile)lprofile
.GetFirst();
AssertEquals(2, p1.GetFunctions().Count);
odb.Close();
DeleteBase(baseName);
}
示例15: TestSubListJava
public virtual void TestSubListJava()
{
System.Collections.IList l = new System.Collections.ArrayList();
l.Add("param1");
l.Add("param2");
l.Add("param3");
l.Add("param4");
int fromIndex = 1;
int size = 2;
int endIndex = fromIndex + size;
System.Collections.IList l2 = l.SubList(fromIndex, endIndex);
AssertEquals(2, l2.Count);
}