Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. object[] initialization as a parameter

object[] initialization as a parameter

Scheduled Pinned Locked Moved C#
questiondata-structures
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    clintsinger
    wrote on last edited by
    #1

    Hi, I have a data source that has the the following method. .Rows.Add(object[] obj} How do I pass directly to it an array of parameters within parenthesis? Like the following ...Rows.Add(1, "Hello", "World", 18); or ...Rows.Add("1", "Hello", "World", "18"); or ...Rows.Add({"1", "Hello", "World", "18"}); I get errors like ...Rows.Add() does not take n parameters where n is equal to the number of values I put in. The last one gives me errors about the {} being all wrong. If I create the following: object[] obj = {1, "Hello", "World", 18}; ...Rows.Add(obj); Everything works fine. Cheers, Clint

    A 1 Reply Last reply
    0
    • C clintsinger

      Hi, I have a data source that has the the following method. .Rows.Add(object[] obj} How do I pass directly to it an array of parameters within parenthesis? Like the following ...Rows.Add(1, "Hello", "World", 18); or ...Rows.Add("1", "Hello", "World", "18"); or ...Rows.Add({"1", "Hello", "World", "18"}); I get errors like ...Rows.Add() does not take n parameters where n is equal to the number of values I put in. The last one gives me errors about the {} being all wrong. If I create the following: object[] obj = {1, "Hello", "World", 18}; ...Rows.Add(obj); Everything works fine. Cheers, Clint

      A Offline
      A Offline
      Andy Moore
      wrote on last edited by
      #2

      Clint, Try this Rows.Add( new object[] { 1, "Hello", "World", 18 } ). Andy Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons

      C 1 Reply Last reply
      0
      • A Andy Moore

        Clint, Try this Rows.Add( new object[] { 1, "Hello", "World", 18 } ). Andy Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons

        C Offline
        C Offline
        clintsinger
        wrote on last edited by
        #3

        Thanks! That did the trick. Cheers, Clint

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups