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. Printing Arrays...

Printing Arrays...

Scheduled Pinned Locked Moved C#
phpdata-structuresquestion
5 Posts 4 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.
  • G Offline
    G Offline
    GRMartin
    wrote on last edited by
    #1

    Does anyone have a function, method or sip of code that will print an array to a multiline string like print_r() will do in PHP? Thank You

    L D 2 Replies Last reply
    0
    • G GRMartin

      Does anyone have a function, method or sip of code that will print an array to a multiline string like print_r() will do in PHP? Thank You

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      string Print(Array arr)
      {
      StringWriter w = new StringWriter()
      foreach (object s in arr)
      {
      w.WriteLine(s);
      }
      return w.ToString();
      }

      top secret
      Download xacc-ide 0.0.3 now!
      See some screenshots

      1 Reply Last reply
      0
      • G GRMartin

        Does anyone have a function, method or sip of code that will print an array to a multiline string like print_r() will do in PHP? Thank You

        D Offline
        D Offline
        Daniel Turini
        wrote on last edited by
        #3

        I don't know neither PHP or print_r, but you could easily join a string with String.Join(Environment.NewLine, yourArray) and print it. Yes, even I am blogging now!

        L 1 Reply Last reply
        0
        • D Daniel Turini

          I don't know neither PHP or print_r, but you could easily join a string with String.Join(Environment.NewLine, yourArray) and print it. Yes, even I am blogging now!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          print_r would print it something like this [0] => [0] => "Value0" [1} => "Value0b" [1] => [0] => "Value1" [1} => "Value1b" [2] => [0] => "Value2" [1} => "Value2b" [3] => [0] => "Value3" [1} => "Value3b" ... [n] => [0] => "Valuen" [1} => "Valuenb" 3-dimensions would branchout 3 times... 4, 4times... you get the drill

          L 1 Reply Last reply
          0
          • L Lost User

            print_r would print it something like this [0] => [0] => "Value0" [1} => "Value0b" [1] => [0] => "Value1" [1} => "Value1b" [2] => [0] => "Value2" [1} => "Value2b" [3] => [0] => "Value3" [1} => "Value3b" ... [n] => [0] => "Valuen" [1} => "Valuenb" 3-dimensions would branchout 3 times... 4, 4times... you get the drill

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            :( sorry it didnt keep the tabs...

            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