本文整理汇总了C#中System.Collections.ArrayList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.IndexOf方法的具体用法?C# ArrayList.IndexOf怎么用?C# ArrayList.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generaCamposRelacion
public static ArrayList generaCamposRelacion(ArrayList tabSelec, ArrayList alias, ArrayList camposRel)
{
ArrayList resp = new ArrayList();
if (camposRel != null)
{
foreach (ArrayList regCam in camposRel)
{
string nombreTabB = (string)regCam[2];
string nombreTabR = (string)regCam[3];
string nombreCampoTB = (string)regCam[4];
string nombreCampoTR = (string)regCam[5];
int indexTB = tabSelec.IndexOf(nombreTabB);
int indexTR = tabSelec.IndexOf(nombreTabR);
string aliasTB = (string)alias[indexTB];
string aliasTR = (string)alias[indexTR];
resp.Add(aliasTB + "." + nombreCampoTB + " = " + aliasTR + "." + nombreCampoTR);
}
}
return resp;
}
示例2: SwapPosition
public static void SwapPosition(ArrayList lista, Object node1, Object node2)
{
int exp1idx = lista.IndexOf(node1);
int exp2idx = lista.IndexOf(node2);
lista.RemoveAt(exp1idx);
lista.Insert(exp1idx, node2);
lista.RemoveAt(exp2idx);
lista.Insert(exp2idx, node1);
}
示例3: Consolidate
public static HashSet<float[]> Consolidate(ArrayList al, int w, int h, TextWriter log)
{
ArrayList al2 = new ArrayList();
foreach (float[] i in al)
{
al2.Add(i);
}
foreach (float[] i in al)
{
foreach (float[] j in al)
{
if (!((Math.Abs(i[0] - j[0]) > w) ||
(Math.Abs(i[1] - j[1]) > h) ||
(Math.Sqrt(Math.Pow(i[0] - j[0], 2) + Math.Pow(i[1] - j[1], 2)) > Math.Sqrt(Math.Pow(w, 2) + Math.Pow(h, 2)))))
{
if (i[2] > j[2])
{
al2[al.IndexOf(j)] = i;
}
else if (i[2] < j[2])
{
al2[al.IndexOf(i)] = j;
}
}
}
}
HashSet<float[]> hash = new HashSet<float[]>();
foreach (float[] i in al2)
{
hash.Add(i);
}
log.WriteLine("The count of al2: " + al2.Count);
log.WriteLine("The count of hash: " + hash.Count);
al.Clear();
foreach (float[] i in hash)
{
al.Add(i);
}
log.WriteLine("The count after hash: " + al.Count);
return hash;
}
示例4: OnInsertFile
public override bool OnInsertFile(ManagerEngine man, IFile file)
{
HttpResponse response = HttpContext.Current.Response;
HttpRequest request = HttpContext.Current.Request;
HttpCookie cookie;
ArrayList chunks;
if ((cookie = request.Cookies["hist"]) == null)
cookie = new HttpCookie("hist");
cookie.Expires = DateTime.Now.AddDays(30);
if (cookie.Value != null) {
chunks = new ArrayList(cookie.Value.Split(new char[]{','}));
if (chunks.IndexOf(man.EncryptPath(file.AbsolutePath)) == -1)
chunks.Add(man.EncryptPath(file.AbsolutePath));
cookie.Value = this.Implode(chunks, ",");
} else
cookie.Value = man.EncryptPath(file.AbsolutePath);
response.Cookies.Remove("hist");
response.Cookies.Add(cookie);
return true;
}
示例5: getPath
//输入必经点集合
public ArrayList getPath(ArrayList pointList, int[,] A, int n,int start)
{
int[,] dist = run(A,n);
bool[] flag = new bool[n + 1];
for (int i = 0; i <= n;i++ )
{
flag[i] = false;
}
ArrayList list = new ArrayList();
list.Add(start);
int reachPoint = start;
for (int i = 0; i < pointList.Count; i++)
{
int min = MAXINT;
for (int j = 1; j <= n; j++)
{
if ((dist[reachPoint, j] < min) && (pointList.IndexOf(j)!=-1) && (!flag[j]))
{
min = dist[reachPoint,j];
reachPoint = j;
flag[j] = true;
list.Add(j);
}
}
}
return list;
}
示例6: fun1
public void fun1()
{
ArrayList a1 = new ArrayList();
a1.Add(1);
a1.Add('c');
a1.Add("string1");
ArrayList al2 = new ArrayList();
al2.Add('a');
al2.Add(5);
int n = (int)a1[0];
Console.WriteLine(n);
a1[0] = 20;
Console.WriteLine(a1.Count);
Console.WriteLine(a1.Contains(55));
Console.WriteLine(a1.IndexOf(55));
//int[] num = (int[])a1.ToArray();
a1.Add(45);
a1.Add(12);
a1.Add(67);
a1.Insert(1, "new value");
//a1.AddRange(al2);
a1.InsertRange(1, al2);
a1.Remove("string1");
a1.RemoveAt(2);
a1.RemoveRange(0, 2);
foreach (object o in a1)
{
Console.WriteLine(o.ToString());
}
}
示例7: GetExcelTables
/// <summary>
/// 获取Excel文件数据表列表
/// </summary>
public static ArrayList GetExcelTables(string ExcelFileName)
{
DataTable dt = new DataTable();
ArrayList TablesList = new ArrayList();
if (File.Exists(ExcelFileName))
{
using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + ExcelFileName))
{
try
{
conn.Open();
dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
}
catch (Exception exp)
{
throw exp;
}
//获取数据表个数
int tablecount = dt.Rows.Count;
for (int i = 0; i < tablecount; i++)
{
string tablename = dt.Rows[i][2].ToString().Trim().TrimEnd('$');
if (TablesList.IndexOf(tablename) < 0)
{
TablesList.Add(tablename);
}
}
}
}
return TablesList;
}
示例8: CycleDigits
private int CycleDigits(
int number
)
{
var diffList = new ArrayList();
var diff = 10;
while (true)
{
if (diff % number != diff)
{
diff = diff % number;
if (diff == 0)
{
return 0;
}
if (diffList.Contains(diff))
{
return diffList.Count - diffList.IndexOf(diff);
}
diffList.Add(diff);
diff = diff * 10;
}
else
{
diff = diff * 10;
}
}
}
示例9: ValtszulopluszSzuloInit
/// <summary>
/// kozos inicializalas
/// </summary>
/// <param name="valtpanelek">
/// valtozaspanelek tombje
/// </param>
/// <param name="szulopanelek">
/// szulopanelek tombje
/// </param>
/// <param name="sajatpanelek">
/// alap panelek tombje vagy null
/// </param>
public void ValtszulopluszSzuloInit(Panel[] valtpanelek, Panel[] szulopanelek, Panel[] sajatpanelek)
{
object[] alap = null;
if (sajatpanelek != null)
alap = new object[] { Alapinfotipus.Alap, sajatpanelek };
object[] valt = null;
object[] szulogy=null;
Panel[] panelek = new Panel[] { panel1, panel2, panel4, panel5 ,panel11};
ArrayList eredetiar = new ArrayList(panelek);
ArrayList ar = new ArrayList(valtpanelek);
bool[] van = new bool[5];
for (int i = 0; i < van.Length; i++)
{
Panel eredeti = (Panel)eredetiar[i];
if (ar.IndexOf(eredeti) != -1)
van[i] = true;
}
for (int i = 0; i < van.Length; i++)
{
if (!van[i])
this.Controls.Remove((Control)eredetiar[i]);
}
if (valtpanelek != null)
{
valt = new object[] { Alapinfotipus.Valtozasok, valtpanelek };
}
if(szulopanelek!=null)
szulogy = new object[] { Alapinfotipus.SzuloGyerekValtozasok, szulopanelek };
if (alap == null)
AlapinfoInit(new object[] { valt, szulogy });
else
AlapinfoInit(new object[] { alap, valt, szulogy });
}
示例10: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
try
{
if(Page.IsPostBack && Request["_BIP_ACTION"] == "AddRelatedDoc" )
{
ArrayList docEnum = new ArrayList();
if(m_Document.RefDocuments != null)
{
foreach(int ids in m_Document.RefDocuments)
docEnum.Add(ids);
}
int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
if(Request["_BIP_ACTION"] == "AddRelatedDoc")
{
if(docEnum.IndexOf(id) == -1)
docEnum.Add(id);
}
m_Document.RefDocuments = docEnum;
m_Document.Update();
}
ddlDocLinks.Items.Clear();
System.Collections.ArrayList docList = new System.Collections.ArrayList();
if(m_Document.ParentId >0)
docList.Add(m_Document.ParentId);
if(m_Document.PreviousVersionId >0)
docList.Add(m_Document.PreviousVersionId);
foreach(object obj in m_Document.RefDocuments)
docList.Add(obj);
DataTable tab =DocumentEnt.FindEnum(docList);
if(tab != null)
{
ddlDocLinks.DataSource = tab;
ddlDocLinks.DataValueField = "Id";
ddlDocLinks.DataTextField = "Header";
ddlDocLinks.DataBind();
tab.Dispose();
}
ddlDocLinks.Items.Insert(0, new ListItem("<" + Bip.Components.BipResources.GetString("StrRelatedDocuments") + ">", "0"));
PanAddDocLink.Visible = m_Document.CanEdit;
if(m_Document.CanEdit || tab != null)
PanOpenRefDocuments.Visible = true;
else PanOpenRefDocuments.Visible = false;
}
catch(Exception ex)
{
ProcessException(ex);
}
}
示例11: fastRemove
internal static int fastRemove(ArrayList a, object o)
{
int num1 = -1;
int num2 = a.Count;
if (num2 > 1000)
{
num1 = a.IndexOf(o, num2 - 50, 50);
}
if (num1 < 0)
{
num1 = a.IndexOf(o);
}
if (num1 >= 0)
{
a.RemoveAt(num1);
}
return num1;
}
示例12: haveSameStringsAtSameIndex
// Helper Method
protected bool haveSameStringsAtSameIndex(ArrayList list1, ArrayList list2)
{
bool haveSameElements = list1.Count == list2.Count;
for (int i = 0; i < list1.Count; ++i)
{
bool sameItemAtIndexI = list1.IndexOf(i) == list2.IndexOf(i);
haveSameElements = haveSameElements && sameItemAtIndexI;
}
return haveSameElements;
}
示例13: getCollectIdList
public ArrayList getCollectIdList(DataSet ds)
{
ArrayList CollectIdList = new ArrayList();
foreach (DataRow row in ds.Tables[0].Rows)
{
if (CollectIdList.IndexOf(row["CollectId"].ToString()) == -1)
CollectIdList.Add(row["CollectId"].ToString());
}
return CollectIdList;
}
示例14: pathCreationDeletion
public string pathCreationDeletion(ArrayList argumentList, int Index, string argument, string path)
{
#region Creates and removes the file paths for the log and dictionary files
Index = argumentList.IndexOf(argument) + 1; // Finds the index of either -f or -l and takes whatever is ahead of it as the new file/log path
path = argumentList[Index].ToString();
argumentList.RemoveAt(Index); // Removes the file/log path arguments to not mess up the query and update commands later
argumentList.RemoveAt(argumentList.IndexOf(argument));
return path;
#endregion
}
示例15: Main
static void Main(string[] args)
{
// Array
Console.WriteLine("Create an Array type collection of Animal objects and use it:");
Animal[] animalArray = new Animal[2]; // Strongly typed
Cow myCow1 = new Cow("Deirdre");
animalArray[0] = myCow1;
animalArray[1] = new Chicken("Ken");
foreach (Animal myAnimal in animalArray)
{
Console.WriteLine("New {0} object added to Array collection, "
+ "Name = {1}", myAnimal.ToString(), myAnimal.Name);
}
Console.WriteLine("Array collection {0} objects.", animalArray.Length);
animalArray[0].Feed(); // invoke Animal method directly
((Chicken)animalArray[1]).LayEgg(); // cast to Chicken to invoke subclass method
Console.WriteLine();
// ArrayList
Console.WriteLine("Create an ArrayList type collection of Animal "
+ "objects and se it:");
ArrayList animalArrayList = new ArrayList(); // A collection of System.Objects
Cow myCow2 = new Cow("Hayley");
animalArrayList.Add(myCow2);
animalArrayList.Add(new Chicken("Row"));
foreach (Animal myAnimal in animalArrayList)
{
Console.WriteLine("New {0} object added to ArrayList collection,"
+ " Name = {1}", myAnimal.ToString(), myAnimal.Name);
}
Console.WriteLine("ArrayList collection contains {0} objects.", animalArrayList.Count);
((Animal)animalArrayList[0]).Feed(); // cast to Animal
((Chicken)animalArrayList[1]).LayEgg(); // cast to Chicken to invoke subclass method
Console.WriteLine();
// Additional ArrayList manipulation
Console.WriteLine("Additional manipulation of ArrayList:");
animalArrayList.RemoveAt(0);
((Animal)animalArrayList[0]).Feed();
animalArrayList.AddRange(animalArray);
((Chicken)animalArrayList[2]).LayEgg();
Console.WriteLine("The animal called {0} is at index {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1));
myCow1.Name = "Janice";
Console.WriteLine("The animal is now called {0}.", ((Animal)animalArrayList[1]).Name);
Console.ReadKey();
}