CoolInterview.com - World's Largest Collection of Interview Questions
Home| Ask Questions| About Us| Feedback| Contact Us|
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies

  • COOLINTERVIEW.COM MICROSOFT C# DETAILS



    Question :
    How to use HASH TABLE,ARRAYLIST in c# explain with example?
    Contact Author  Contact Author


    Answer :
    The ArrayList object is a collection of items containing a single data value.

    Items are added to the ArrayList with the Add() method.
    The following code creates a new ArrayList object named mycountries and four items are added:
    <script runat="server">
    Sub Page_Load
    if Not Page.IsPostBack then
    dim mycountries=New ArrayList
    mycountries.Add("Norway")
    mycountries.Add("Sweden")
    mycountries.Add("France")
    mycountries.Add("Italy")
    end if
    end sub
    </script>
    U can sort it alphabetically
    mycountries.Sort()
    By default, an ArrayList object contains 16 entries. An ArrayList can be sized to its final size with the TrimToSize() method:
    mycountries.TrimToSize()
    For reversing
    mycountries.Reverse()
    With DB
    rb.DataSource=mycountries
    rb.DataBind()



    The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

    Items are added to the Hashtable with the Add() method.

    The following code creates a Hashtable named mycountries and four elements are added:

    <script runat="server">
    Sub Page_Load
    if Not Page.IsPostBack then
    dim mycountries=New Hashtable
    mycountries.Add("N","Norway")
    mycountries.Add("S","Sweden")
    mycountries.Add("F","France")
    mycountries.Add("I","Italy")
    end if
    end sub
    </script>


    With DB

    <html>
    <body><form runat="server">
    <asp:RadioButtonList id="rb" runat="server"
    AutoPostBack="True" /></form></body>
    </html>

    ----
    <script runat="server">
    sub Page_Load
    if Not Page.IsPostBack then
    dim mycountries=New Hashtable
    mycountries.Add("N","Norway")
    mycountries.Add("S","Sweden")
    mycountries.Add("F","France")
    mycountries.Add("I","Italy")
    rb.DataSource=mycountries rb.DataValueField="Key" rb.DataTextField="Value" rb.DataBind()
    end if
    end sub
    </script><html>
    <body><form runat="server">
    <asp:RadioButtonList id="rb" runat="server"
    AutoPostBack="True" /></form></body>
    </html>

     Posted by: Rajnee    

    Contact Author  Contact Author

    © CoolInterview.com
    Today's Special: Get Free Magazine from SAP now!

    A D V E R T I S E M E N T








    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       


    Rate the above answer. Help us to know about the answer.
    Category C# Interview Questions
    Rating (4.0) By 1 users
    Added 7/27/2007 12:59:25 PM
    Views 3140
    Rate it!
    Free Offers 300 Free Magazines for you. No credit card required. No Shipping Charges. Absolutely Free for 1 Year.

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL C# Interview Questions


    Sponsored Links  

    Google Search

    Google

    CoolInterview.com is a part of Vyom Network.
    Copyright ©2003-2009 Vyom Technosoft Pvt. Ltd., All Rights Reserved. Privacy Policy
    Page URL: http://www.coolinterview.com/interview/11513/Default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial

    1.02