+ Reply to Thread
Results 1 to 2 of 2
  1. Junior Member
    Join Date
    Nov 2007
    Posts
    19
    #1

    Default new object new arraylist

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;

    namespace ConsoleApplication3
    {
    class Program
    {
    static void Main(string[] args)
    {
    object o = "testObject";

    ArrayList myArrayList_1 = new ArrayList();
    myArrayList_1.Add("abc");
    myArrayList_1.Add(123);
    myArrayList_1.Add(o);

    string[] myStringArray_1 = new string[] { "hello ", "secure ", "world " };
    myArrayList_1.AddRange(myStringArray_1);

    object[] myObjectArray_1= new object[]{new object() , new ArrayList()}; // LINE OF CODE 01

    myArrayList_1.AddRange(myObjectArray_1); // LINE OF CODE 02


    }
    }
    }


    // CAN YOU EXPLAIN ME THE THE
    // LINE OF CODE 01
    //AND
    // LINE OF CODE 02
    //
    //

    Reply With Quote Quote  

  2. Junior Member
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    29

    Certifications
    MCP sql server, MCTS Web, MCTS Windows, MCTS Distributed - MCPD Enterprise Developer
    #2
    Code:
     object[] myObjectArray_1= new object[]{new object() , new ArrayList()}; // LINE OF CODE 01
    That line creates an instance of an object array and populates it with an object instance, and an arrayList instance

    Code:
     myArrayList_1.AddRange(myObjectArray_1); // LINE OF CODE 02
    Adds the elements of myObjectArray to the myArrayList_1 ArrayList.[/code]
    Reply With Quote Quote  

+ Reply to Thread

Social Networking & Bookmarks