CoolInterview.com - World's Largest Collection of Interview Questions
 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


  • INTERVIEW QUESTIONS MICROSOFT C# DETAILS
    Question :
    How to use HASH TABLE,ARRAYLIST in c# explain with example?
    Contact   Contact
    Category C# Interview Questions
    Rating (4.5) By 2 users
    Added on 7/27/2007 12:59:25 PM
    Views 3376
    Rate it!
    Answers:

    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 Rajnee  Contact Rajnee


    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

       
    Related Questions
    View Answer
    Assemblies are of the following types:

    View Answer
    What is the difference between shadow and override

    View Answer
    What is the top .NET class that everything is derived from?

    View Answer
    C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

    View Answer
    When you inherit a protected class-level variable?Who is it available to?

    View Answer
    Does C# support multiple inheritance?

    View Answer

    How do you inherit from a class in C#?


    View Answer
    What is an abstract class?

    View Answer
    What does the keyword virtual mean in the method definition?

    View Answer
    How's method overriding different from overloading?

    View Answer

    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

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/11513/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.47