Item is certainly available through C#. It's part of the .NET
Framework class, it doesn't disappear.  You just don't need to use the
word Item.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsarraylistclassitemtopic.asp

ArrayList al;
Object o = al[i]; //<--Indexer for array list class is the Item property.

In either case you need to cast the value back into your actual type,
because the Item property returns an object.

  public static void PrintIndexAndValues(ArrayList myList )
   {
       RelationRep rr = null;
       for(int i=0; i < myList.Count; i++){
          rr=  (RelationRep)myList[i];
           Console.WriteLine( "\t[{0}]:\t{1}", i, rr.accountNum);
     }


}


        }




On Apr 11, 2005 11:50 PM, Rinki Agarwal <[EMAIL PROTECTED]> wrote:
> 
> Hi Everyone,
>  I am trying to retrieve items from an arraylist. I did this before in VB.net 
> using Arrylist.item, but this property is not available in C#. I tried to get 
> the value through myEnumerator.Current. This is not returning the actual 
> value of the array list. It is returning the name of the class.arrylist name. 
> I really need to get hold of the value of the arraylist and store it in a 
> varaible. I tried response.write, but that did not work either. Is there any 
> way I can get the value of all three individual items that I stored in the 
> array list.
> Below is my code. Any help will be greatly appreciated .
> 
> public class RelationRep
>       {
>               private string AccountNum;
>               private string typeNum;
>               private string typeName;
>               public RelationRep(string AccountNum, string typeNum, string 
> typeName)
>               {
>                       this.AccountNum=AccountNum;
>                       this.typeNum=RelationNum;
>                       this.typeName=RelationName;
>               }
>               public string accountNum { get{return AccountNum;}}
>               public string typeNum {get{return typeNum;}}
>               public string typeName {get{return TypeName;}}
>       }
>               private void btnSubmit_Click(object sender, System.EventArgs e)
>               {
>                       System.Web.UI.WebControls.CheckBox 
> chkAccountNumSelected;
>                       ArrayList Relation = new ArrayList();
>                       RelationRep  rr;
>                       foreach (DataGridItem AcctDataGridItems in 
> dgAccntNum.Items)
>                       {
>                               
> chkAccountNumSelected=(CheckBox)AcctDataGridItems.FindControl("chkAccountNum");
>                               if (chkAccountNumSelected.Checked)
>                               {
>                                       Label lblAccountNum = 
> (Label)AcctDataGridItems.FindControl("lblacct_no");
>                                       Label  
> lbltypeNum=(Label)AcctDataGridItems.FindControl("lbltypeNo");
>                                       Label  
> lbltypeName=(Label)AcctDataGridItems.FindControl("lblTypeName");
>                                       Relation.Add(new 
> RelationRep(lblAccountNum.Text, lbltypeNum.Text, lbltypeName.Text));
>                               }
>                       }
> 
>                               PrintIndexAndValues(Relation);
>               }
>               public static void PrintIndexAndValues( IEnumerable myList )
>               {
>                       int i = 0;
>                       System.Collections.IEnumerator myEnumerator = 
> myList.GetEnumerator();
>                       while ( myEnumerator.MoveNext() )
>                               Console.WriteLine( "\t[{0}]:\t{1}", i++, 
> myEnumerator.Current);
>                       Console.WriteLine();
>          }
> 
> Thanks.
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> 
> [Non-text portions of this message have been removed]
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to