当前位置: 首页>>代码示例>>C#>>正文


C# ArrayList.IndexOf方法代码示例

本文整理汇总了C#中ArrayList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.IndexOf方法的具体用法?C# ArrayList.IndexOf怎么用?C# ArrayList.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayList的用法示例。


在下文中一共展示了ArrayList.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: playWithArrayList

        static void playWithArrayList()
        {
            ArrayList lst = new ArrayList() {1,2,3};
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            int a = 0;
            lst.Add(a = 15);
            lst.Add(null);
            lst.Add(new Car("diesel", 150, 200));
            lst.Add(10.25f);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.Insert(2, "insert");
            lst.Add(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.RemoveAt(1);
            lst.Add(a);
            lst.Remove(a);
            lst.Remove(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            Console.WriteLine(lst.IndexOf(15));

            foreach (Object obj in lst)
                Console.WriteLine(obj);
        }
开发者ID:NivekAlunya,项目名称:csharp,代码行数:27,代码来源:Program.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        SettingsPropertyCollection profileProperties = ProfileCommon.Properties;

        string[] settings;
        ArrayList keys = new ArrayList();
        ArrayList alias = new ArrayList();
        ArrayList name = new ArrayList();
        foreach (SettingsProperty prop in profileProperties)
        {
            if (prop.Attributes["CustomProviderData"].ToString() != "None")
            {
                settings = prop.Attributes["CustomProviderData"].ToString().Split(';');
                name.Add(settings[1] + prop.Name);
                alias.Add(settings[1] + settings[0]);
            }
        }
        name.Sort();
        alias.Sort();

        ArrayList name1 = ArrayList.Repeat("", name.Count);
        foreach (String item in name) name1[name.IndexOf(item)] = item.Substring(1);

        ArrayList alias1 = ArrayList.Repeat("", alias.Count);
        foreach (String item in alias) alias1[alias.IndexOf(item)] = item.Substring(1);

        int n = 0;
        StringDictionary properties = new StringDictionary();
        foreach (string item in name1) { properties[item] = alias1[n].ToString(); n++; }

        rptProfile.DataSource = properties;
        rptProfile.DataBind();
    }
开发者ID:edobry,项目名称:Robotics-Team-375-Website,代码行数:33,代码来源:profile.ascx.cs

示例3: Main

    public static void Main (string[] args) {

      var al = new ArrayList();      

      al.Add("zero");
      al.Add("one");
      al.Add("two");

      al.IndexOf("zero");
      Console.WriteLine(al.Count);
      Console.WriteLine(al[0]);
      Console.WriteLine(al[1]);
      Console.WriteLine(al[2]);

      al[1] = "one-updated"; 
      Console.WriteLine(al[1]); // this used to fail

    }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:18,代码来源:ArrayListIndexer.cs

示例4: Start

    // Use this for initialization
    void Start()
    {
        //creates an array of an undetermined size and type
        ArrayList aList = new ArrayList();

        //create an array of all objects in the scene
        Object[] AllObjects = GameObject.FindObjectsOfType(typeof(Object)) as Object[];

        //iterate through all objects
        foreach (Object o in AllObjects)
        {
            if (o.GetType() == typeof(GameObject))
            {
                aList.Add(o);
            }
        }

        if (aList.Contains(SpecificObject))
        {
            Debug.Log(aList.IndexOf(SpecificObject));
        }

        if (aList.Contains(gameObject))
        {
            aList.Remove(gameObject);
        }

        //initialize the AllGameObjects array
        AllGameObjects = new GameObject[aList.Count];

        //copy the list to the array
        DistanceComparer dc = new DistanceComparer();
        dc.Target = gameObject;
        aList.Sort(dc);

        aList.CopyTo(AllGameObjects);
        ArrayList sorted = new ArrayList();
        sorted.AddRange(messyInts);
        sorted.Sort();
        sorted.Reverse();
        sorted.CopyTo(messyInts);
    }
开发者ID:kurtzhang,项目名称:UnityProjects,代码行数:43,代码来源:ArrayLists.cs

示例5: getRouteBFS

    public ArrayList getRouteBFS()
    {
        ArrayList path = new ArrayList();

        Boolean[] visited = new Boolean[NUM_NODES];
        for (int i = 0; i < NUM_NODES; i++) { visited[i] = false; }

        Queue queue = new Queue();
        queue.Enqueue(0);         //Add origin

        int it = 0;
        while (queue.Count != 0 && it <= LEVELS)
        {
            int parent = (int)queue.Dequeue();
            path.Add(parent);
            visited[parent] = true;

            ArrayList childs = new ArrayList();
            for (int i = 0; i < NUM_NODES; i++) {
                int   childPos   = i;
                float childValue = nodeValues[childPos];
                if (((nodeEdges[parent, childPos] == INF) && (nodeEdges[childPos, parent] == INF)) || //No edges
                    visited[childPos]) {                                                              //If the node isn't visited
                    childValue = INF;
                }
                childs.Add(childValue);
            }
            ArrayList values = new ArrayList(childs);
            values.Sort();
            float minValue = (float)values[0];
            int   indexMax = childs.IndexOf(minValue);

            if ((indexMax != -1) && (minValue < INF)) {
                queue.Enqueue(indexMax);
            }

            it++;
        }

        return path;
    }
开发者ID:rivadunga,项目名称:SpaceFall,代码行数:41,代码来源:GraphPath.cs

示例6: UpdateTracks

    private void UpdateTracks(CvBlobs blobs, List<Trak> tracks, double minDist, int maxLife)
    {
        ArrayList matched = new ArrayList();
        List<int> enter = new List<int>();
        List<int> end = new List<int>();
        List<int> active = new List<int>();

        foreach (var blob in blobs)
        {
            Vector2 blobPos = TransformKinectToScreenPos(new Vector2((float)blob.Value.Centroid.X, (float)(blob.Value.Centroid.Y)));
            float distanceFromCenter = Vector2.Distance(blobPos, new Vector2(Screen.width / 2, Screen.height / 2));

            if (distanceFromCenter < ((Screen.height / 2) - radiusRemove))//check Centroid is inside Pond Bounds
            {
                //Debug.Log("Inbounds");
                bool tracked = false;
                double minFound = 1000.0;
                Trak closest = new Trak();

                //Find if blob is being tracked
                foreach (Trak track in tracks)
                {

                    double distance = Vector2.Distance(new Vector2((float)blob.Value.Centroid.X, (float)blob.Value.Centroid.Y), new Vector2((float)track.X, (float)track.Y));
                    if (distance < minDist)
                    {
                        //Debug.Log("Found Closest");

                        tracked = true;
                        if (distance < minFound)
                        {
                            closest = track;
                            minFound = distance;
                        }
                    }
                }
                if (tracked)
                {
                    //Debug.Log("updating tracked");

                    //Ok it is tracked! do your stuff blob!
                    closest.Active++;
                    closest.Inactive = 0;
                    closest.Lifetime++;
                    closest.Label = blob.Key;
                    closest.X = blob.Value.Centroid.X;
                    closest.Y = blob.Value.Centroid.Y;
                    closest.Centroid = blob.Value.Centroid;
                    closest.MaxX = blob.Value.MaxX;
                    closest.MaxY = blob.Value.MaxY;
                    closest.MinX = blob.Value.MinX;
                    closest.MinY = blob.Value.MinY;
                    matched.Add(closest.Id);
                    tracked = true;
                    active.Add((int)closest.Id);
                    //break;
                }
                else
                {
                    //Debug.Log("New track");

                    //Blob Is not tracked? create new trak
                    trakCount++;
                    Trak track = new Trak();
                    track.Active = 1;
                    track.Inactive = 0;
                    track.Lifetime = 1;
                    track.Label = blob.Key;
                    track.X = blob.Value.Centroid.X;
                    track.Y = blob.Value.Centroid.Y;
                    track.Centroid = blob.Value.Centroid;
                    track.MaxX = blob.Value.MaxX;
                    track.MaxY = blob.Value.MaxY;
                    track.MinX = blob.Value.MinX;
                    track.MinY = blob.Value.MinY;
                    track.Id = trakCount;
                    tracks.Add(track);
                    enter.Add((int)track.Id);
                }
            }
        }
        for (int i = 0; i < tracks.Count; i++)
        {
            Trak track = (Trak)tracks[i];
            if (matched.IndexOf(track.Id) == -1)
            {
                if (track.Inactive >= maxLife)
                {
                    //Tracked object left, this track is leaving
                    end.Add((int)track.Id);
                }
                else
                {
                    //this track was not matched, let's wait maxLife frames
                    track.Active = 0;
                    track.Inactive++;
                    track.Lifetime++;
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:Titoulion,项目名称:Shoal,代码行数:101,代码来源:KinectOpenCvDetector.cs

示例7: OrganizeByMaterial

	// Organizes all sprites by associating them with the
	// material they use. Returns an array list of
	// MaterialSpriteLists:
	List<MaterialSpriteList> OrganizeByMaterial(ArrayList sprites)
	{
		// A list of all materials
		ArrayList materials = new ArrayList();
		// The map of materials to sprites
		List<MaterialSpriteList> map = new List<MaterialSpriteList>();
		// The material of the sprite:
		Material mat;

		SpriteRoot sprite;
		MaterialSpriteList matSpriteList;
		int index;

		for (int i = 0; i < sprites.Count; ++i)
		{
			sprite = (SpriteRoot)sprites[i];

			if (sprite.spriteMesh == null)
			{
				// See if it is because the sprite isn't associated
				// with a manager:
				if (sprite.managed)
				{
					// See if we can get the material
					// from an associated manager:
					if (sprite.manager != null)
					{
						mat = sprite.manager.renderer.sharedMaterial;
					}
					else // Else, no manager associated!:
					{
						EditorUtility.DisplayDialog("ERROR", "Sprite \"" + sprite.name + "\" is not associated with a SpriteManager, and can therefore not be included in the atlas build.", "Ok");
						Selection.activeGameObject = sprite.gameObject;
						return null;
					}
				}
				else // Else get the material from the sprite's renderer
				{	 // as this is probably a prefab and that's why it
					// doesn't have a mesh:
					mat = sprite.renderer.sharedMaterial;
				}
			}
			else if (sprite.managed)
			{
				if (sprite.manager != null)
				{
					mat = sprite.manager.renderer.sharedMaterial;
				}
				else // Else, no manager associated!:
				{
					EditorUtility.DisplayDialog("ERROR", "Sprite \"" + sprite.name + "\" is not associated with a SpriteManager, and can therefore not be included in the atlas build.", "Ok");
					Selection.activeGameObject = sprite.gameObject;
					return null;
				}
			}
			else
				mat = sprite.spriteMesh.material;

			index = materials.IndexOf(mat);

			// See if the material is already in our list:
			if (index >= 0)
			{
				matSpriteList = (MaterialSpriteList)map[index];
				matSpriteList.sprites.Add(sprite);
			}
			else
			{
				// Validate that the sprite had a material:
				if (mat == null)
				{
					EditorUtility.DisplayDialog("ERROR: No material selected", "No material selected for sprite \"" + sprite.name + "\"!  Please set a material and try again.  Click OK to go directly to the sprite that generated this error.", "Ok");
					Selection.activeGameObject = sprite.gameObject;
					return null;
				}

				materials.Add(mat);
				matSpriteList = new MaterialSpriteList();
				matSpriteList.material = mat;
				matSpriteList.sprites.Add(sprite);

				map.Add(matSpriteList);
			}
		}

		return map;
	}
开发者ID:Nilesh410451,项目名称:archery-master,代码行数:90,代码来源:BuildAtlases.cs

示例8: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //string SessionIDName = "VGI022_" + PageTimeStamp.Value;
            //DataTable dt = (DataTable)Session[SessionIDName];
            //DataRow dr = dt.Rows[100];
            //dr["aSD"] = "100";
            AuthorityControls(this);

            ErrorMsgLabel.Text = "";
            //txtPickBatch.Text = "1";
            //------------------------------------------------------
            if (!Page.IsPostBack)
            {
                if (this.Request["mode"].ToString().ToUpper() == "VIEW")
                {
                    string sAssignNo = this.Request["ID"].ToString().ToUpper();

                    if (Session["VGI02QueryID"] != null)
                    {

                        IDList = (ArrayList)Session["VGI02QueryID"];
                        if (IDList.IndexOf(sAssignNo) == -1)
                            IDList.Add(sAssignNo);
                    }
                    else
                    {
                        IDList.Clear();
                        IDList.Add(sAssignNo);
                        Session["VGI02QueryID"] = IDList;
                    }
                }

                else if (this.Request["mode"].ToString().ToUpper() == "NEW")
                {
                    //          ScriptManager.RegisterStartupScript(Page, this.GetType(), "VGI022.aspx", "confirm(' 此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');", true);
                    this.btn_CancelM.Attributes.Add("onclick", "javascript:return confirm('此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');");
                    this.btn_Find.Attributes.Add("onclick", "javascript:return confirm('此動作將會切換到系統其他頁面,請確認資料已儲存,您確定要切換嗎? ');");

                    this.btn_Save.Attributes.Add("onclick", "javascript:return confirm('確定儲存指配點貨單?');");
                    //      function GotoAcceptQty(destChanNo , destStore , destIteem , destPeriod , destAcceptDate , destAcceptQty )

                    //        TextBox txtChanNo = (TextBox)this.SLP_CHAN_NO.FindControl("TextBoxCode");
                    //        TextBox txtSTORE = (TextBox)this.SLP_STORE.FindControl("TextBoxCode");
                    TextBox txtSKU = (TextBox)this.SLP_SKU.FindControl("TextBoxCode");
                    TextBox txtPeriod = (TextBox)this.SLP_Period.FindControl("TextBoxCode");
                    TextBox txtAcceptDate = (TextBox)this.SLP_AcceptDate.FindControl("TextBoxCode");
                    TextBox txtAccept = (TextBox)this.SLP_Accept.FindControl("TextBoxCode");
                    //
                    txtSKU.Attributes.Add("onblur", "GotoItemPeriod('" + txtPeriod.ClientID + "')");

                    //           txtPeriod.Attributes.Add("onblur", "GotoAcceptQty('" + txtChanNo.ClientID + "','" + txtSTORE.ClientID + "','" + txtSKU.ClientID 
                    //                                                                + "','" +  txtPeriod.ClientID + "','" + txtAcceptDate.ClientID + "','" + txtAccept.ClientID  + "')");
                    txtPeriod.Attributes.Add("onblur", "GotoAcceptQty()");

                    //      txtAccept.Attributes.Add("onFocus", "CheckAcceptData()");
                    txtAccept.Attributes.Add("onkeydown", "return TTLQytWarning();");
                    //this.ddlChanNo.Attributes["onchange"] = "GetStoreData(document.getElementById('" + this.ddlChanNo.ClientID + "'));";

                    //             this.ddlChanNo.Attributes["onblur"] = "document.getElementById('" + ddlStore.ClientID + "').focus();";
                    this.ddlStore.Attributes["onblur"] = "document.getElementById('" + txtSKU.ClientID + "').focus();";

                }
                //         this.btn_CancelD.Attributes.Add("onclick", "AddNewItem()");
                //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );

                this.txt_PageStatus.Text = "NEW";
                GetPageDefault();
                //         throw new Exception("明細資料在編輯狀態,不可儲存!!");           
                ToolBarInit();
                //if (this.txt_PageStatus.Text != "QUERY")
                //{
                //    ScriptManager.RegisterStartupScript(
                //                                                 this.UpdatePanel7,
                //                                                 typeof(UpdatePanel),
                //                                                 "隨便寫",
                //                                                 "document.getElementById('" + this.ddlChanNo.ClientID + "').focus();", true);

                //}

            }
            //else
            //{
            //    if (ddlChanNo.Items.Count > 0)
            //    {
            //        MaintainAssign BCO = new MaintainAssign(ConntionDB);
            //        DataTable Dt = BCO.GetStoreByChanNo(ddlChanNo.SelectedItem.Value);
            //        this.ddlStore.DataSource = Dt;
            //        ddlStore.DataTextField = "name";
            //        ddlStore.DataValueField = "store";
            //        ddlStore.DataBind();
//.........这里部分代码省略.........
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:101,代码来源:VGI022.aspx.cs

示例9: Optimize

    public static void Optimize(ArrayList list)
    {
        for (int i = 1; i < list.Count; i++)
        {
            X86Code x0 = list[i] as X86Code;
            if (x0 == null || x0.ignore || x0.IsBrTarget) continue;

            ArrayList listx = new ArrayList();
            listx.Add(x0);
            for (int j = 1;; j++)
            {
                X86Code xx = GetPrevious(list, i, j);
                if (xx == null) break;
                listx.Add(xx);
            }
            if (listx.Count < 2) continue;

            X86Code[] x = listx.ToArray(typeof(X86Code)) as X86Code[];
            if (IsMovEtc(x[0].Mnemonic) && !IsXS(x[0].Operand1) && IsXX(x[0].Operand2) && x[0].Operand1 != x[0].Operand2)
            {
                for (int j = 1; j < x.Length; j++)
                {
                    if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand2 && !IsXS(x[j].Operand2)
                        && !(IsAddr(x[0].Operand1) && IsAddr(x[j].Operand2)))
                    {
                        if (x[0].Operand1 != x[j].Operand2 && (IsXX(x[0].Operand1) || IsXX(x[j].Operand2)))
                        {
                            x[j].Ignore();
                            x[0].Ignore();
                            X86Code xx = new X86Code(x[0].Mnemonic, x[0].Operand1, x[j].Operand2);
                            xx.Notes = "[optimize] add";
                            list.Insert(i + 1, xx);
                        }
                    }
                    else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[0].Operand2)
                    {
                        continue;
                    }
                    break;
                }
                if (x[0].ignore) continue;
            }
            switch (x[0].Mnemonic)
            {
                case "pop":
                {
                    Hashtable t = new Hashtable();
                    for (int j = 1; j < x.Length; j++)
                    {
                        if (x[j].Mnemonic == "push")
                        {
                            if (!t.Contains(x[j].Operand1))
                            {
                                if (x[j].Operand1 == x[0].Operand1)
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                }
                                else if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1))
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                    X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1);
                                    xx.Notes = "[optimize] add";
                                    list.Insert(i + 1, xx);
                                }
                            }
                            else if (!t.Contains(x[0].Operand1))
                            {
                                if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1))
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                    X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1);
                                    xx.Notes = "[optimize] add";
                                    i = list.IndexOf(x[j]);
                                    list.Insert(i + 1, xx);
                                }
                            }
                        }
                        else if (IsMovEtc(x[j].Mnemonic))
                        {
                            t[x[j].Operand1] = true;
                            continue;
                        }
                        break;
                    }
                    break;
                }
                case "cmp":
                    if (IsXX(x[0].Operand1) && IsDigit(x[0].Operand2))
                    {
                        for (int j = 1; j < x.Length; j++)
                        {
                            if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand1)
                            {
                                x[j].Ignore();
                                x[0].Ignore();
                                X86Code xx = new X86Code("cmp", x[j].Operand2, x[0].Operand2);
                                xx.Notes = "[optimize] add";
//.........这里部分代码省略.........
开发者ID:higepon,项目名称:mona,代码行数:101,代码来源:X86Code.cs

示例10: CheckDup_Chan_NO

 private string CheckDup_Chan_NO()
 {
     string strMsg = "";
     int iDup = 0;
     ArrayList arrDupData = new ArrayList();
     for (int i = 0; i < Repeater1.Items.Count; i++)
     {
         iDup = 0;
         string strCHAN_NO1 = ((Label)Repeater1.Items[i].FindControl("lblCHAN_NO")).Text;
         if (arrDupData.IndexOf(strCHAN_NO1) == -1)
         {
             for (int j = 0; j < Repeater1.Items.Count; j++)
             {
                 string strCHAN_NO2 = ((Label)Repeater1.Items[j].FindControl("lblCHAN_NO")).Text;
                 if (strCHAN_NO1 == strCHAN_NO2)
                     iDup++;
             }
             if (iDup > 1)
             {
                 arrDupData.Add(strCHAN_NO1);
                 strMsg += "配本通路[" + strCHAN_NO1 + "]有重複資料<br/>";
             }
         }
     }
     return strMsg;
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:26,代码来源:ITM072.aspx.cs

示例11: OrganizeByMaterial

	// Organizes all sprites by associating them with the
	// material they use. Returns an array list of
	// MaterialSpriteLists:
	List<MaterialSpriteList> OrganizeByMaterial(ArrayList sprites)
	{
		string errString = "";

		// A list of all materials
		ArrayList materials = new ArrayList();
		// The map of materials to sprites
		List<MaterialSpriteList> map = new List<MaterialSpriteList>();
		// The material of the sprite:
		Material mat;

		ISpriteAggregator sprite;
		MaterialSpriteList matSpriteList;
		int index;

		for (int i = 0; i < sprites.Count; ++i)
		{
			sprite = (ISpriteAggregator)sprites[i];

			mat = sprite.GetPackedMaterial(out errString);

			if(mat == null)
			{
				if (haltOnNullMaterial)
				{
					EditorUtility.DisplayDialog("ERROR", errString, "Ok");
					Selection.activeGameObject = sprite.gameObject;
					return null;
				}
				else
				{
					Debug.LogError(errorString);
					continue;
				}
			}

			index = materials.IndexOf(mat);

			// See if the material is already in our list:
			if (index >= 0)
			{
				matSpriteList = (MaterialSpriteList)map[index];
				matSpriteList.sprites.Add(sprite);
			}
			else
			{
				materials.Add(mat);
				matSpriteList = new MaterialSpriteList();
				matSpriteList.material = mat;
				matSpriteList.sprites.Add(sprite);

				map.Add(matSpriteList);
			}
		}

		return map;
	}
开发者ID:AtrapadosGame,项目名称:AtrapadosGame,代码行数:60,代码来源:BuildAtlases.cs

示例12: CompareObjects


//.........这里部分代码省略.........
            DoIEnumerableTest(ienm1, ienm2, good, bad, hsh1, true);
        }
        catch
        {
            hsh1["GetEnumerator"] = "(int, int)";
        }

        //GetRange
        good.Clear();
        for (int i = 0; i < 100; i++)
            good.Add(i);

        ArrayList alst1 = good.GetRange(0, good.Count);
        try
        {
            ArrayList alst2 = bad.GetRange(0, good.Count);
            for (int i = 0; i < good.Count; i++)
            {
                if (alst1[i] != alst2[i])
                    hsh1["GetRange"] = i;
            }
        }
        catch
        {
            hsh1["Range"] = "(int, int)";
        }

        //IndexOf(Object, int)

        if (bad.Count > 0)
        {
            for (int i = 0; i < good.Count; i++)
            {
                if (good.IndexOf(good[i], 0) != bad.IndexOf(good[i], 0))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (good.IndexOf(good[i], i) != bad.IndexOf(good[i], i))
                {
                    hsh1["IndexOf"] = "(Object, int)";
                }
                if (i < (good.Count - 1))
                {
                    if (good.IndexOf(good[i], i + 1) != bad.IndexOf(good[i], i + 1))
                    {
                        hsh1["IndexOf"] = "(Object, int)";
                    }
                }
            }

            try
            {
                bad.IndexOf(1, -1);
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                hsh1["IndexOf"] = ex;
            }

            try
            {
                bad.IndexOf(1, bad.Count);
            }
开发者ID:noahfalk,项目名称:corefx,代码行数:67,代码来源:WrapperTests.cs

示例13: TestMultiDataTypes

    public void TestMultiDataTypes()
    {
        short i16 = 1;
        int i32 = 2;
        long i64 = 3;
        ushort ui16 = 4;
        uint ui32 = 5;
        ulong ui64 = 6;

        ArrayList alst = new ArrayList();
        alst.Add(i16);
        alst.Add(i32);
        alst.Add(i64);
        alst.Add(ui16);
        alst.Add(ui32);
        alst.Add(ui64);

        //[] we make sure that ArrayList only return true for Contains() when both the value and the type match 
        //in numeric types
        for (int i = 0; i < alst.Count; i++)
        {
            Assert.True(!alst.Contains(i) || i == 2);
        }

        //[]IndexOf should also work in this context
        for (int i = 0; i < alst.Count; i++)
        {
            Assert.True((alst.IndexOf(i) != -1) || (i != 2));
            Assert.True((alst.IndexOf(i) == -1) || (i == 2));
        }

        //[]Sort should fail cause the objects are of different types
        Assert.Throws<InvalidOperationException>(() => alst.Sort());
    }
开发者ID:noahfalk,项目名称:corefx,代码行数:34,代码来源:WrapperTests.cs

示例14: SetupControl


//.........这里部分代码省略.........
                    ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes);
                }

                if (ucMyNotifications != null)
                {
                    ucMyNotifications.Visible = false;
                    ucMyNotifications.StopProcessing = true;
                }

                if (ucMyMessages != null)
                {
                    ucMyMessages.Visible = false;
                    ucMyMessages.StopProcessing = true;
                }

                if (ucMyFriends != null)
                {
                    ucMyFriends.Visible = false;
                    ucMyFriends.StopProcessing = true;
                }

                if (ucMyMemberships != null)
                {
                    ucMyMemberships.Visible = false;
                    ucMyMemberships.StopProcessing = true;
                }

                if (ucMyCategories != null)
                {
                    ucMyCategories.Visible = false;
                    ucMyCategories.StopProcessing = true;
                }

                tabMenu.SelectedTab = activeTabs.IndexOf(page);

                // Select current page
                switch (page)
                {
                    case personalTab:
                        if (myProfile != null)
                        {
                            // Get alternative form info
                            AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName);
                            if (afi != null)
                            {
                                myProfile.StopProcessing = false;
                                myProfile.Visible = true;
                                myProfile.AllowEditVisibility = AllowEditVisibility;
                                myProfile.AlternativeFormName = AlternativeFormName;
                            }
                            else
                            {
                                lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName);
                                lblError.Visible = true;
                                myProfile.Visible = false;
                            }
                        }
                        break;

                    // My details tab
                    case detailsTab:
                        if (ucMyDetails != null)
                        {
                            ucMyDetails.Visible = true;
                            ucMyDetails.StopProcessing = false;
                            ucMyDetails.SetValue("Customer", customer);
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:67,代码来源:MyAccount.ascx.cs

示例15: TestDuplicatedItems

        public void TestDuplicatedItems()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;

            string[] strHeroes =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Daniel Takacs",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Gene",
                "Thor",
                "Wildcat",
                null
            };

            // Construct ArrayList.
            arrList = new ArrayList(strHeroes);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone()};

            foreach (ArrayList arrayListType in arrayListTypes)
            {

                arrList = arrayListType;
                //
                // []  IndexOf an array normal
                //
                for (int i = 0; i < strHeroes.Length; i++)
                {
                    Assert.Equal(i, arrList.IndexOf(strHeroes[i]));
                }


                //[]  Check IndexOf when element is in list twice
                arrList.Clear();
                arrList.Add(null);
                arrList.Add(arrList);
                arrList.Add(null);

                Assert.Equal(0, arrList.IndexOf(null));

                //[]  check for something which does not exist in a list
                arrList.Clear();
                Assert.Equal(-1, arrList.IndexOf(null));
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:71,代码来源:IndexOfTests.cs


注:本文中的ArrayList.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。