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. give me sample example code for passing array data to other function

give me sample example code for passing array data to other function

Scheduled Pinned Locked Moved C#
data-structureshelptutorialquestion
7 Posts 3 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.
  • P Offline
    P Offline
    premkamalg
    wrote on last edited by
    #1

    hi, plz help i want to send array(string data ) data to other function how can i send that data plz give me sample code for that

    G 1 Reply Last reply
    0
    • P premkamalg

      hi, plz help i want to send array(string data ) data to other function how can i send that data plz give me sample code for that

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      public void DoSomething(string[] values) {
      foreach (string value in values) {
      Console.WriteLine(value);
      }
      }

      DoSomething(new string[] { "A text line.", "Another line." });

      --- b { font-weight: normal; }

      G P 2 Replies Last reply
      0
      • G Guffa

        public void DoSomething(string[] values) {
        foreach (string value in values) {
        Console.WriteLine(value);
        }
        }

        DoSomething(new string[] { "A text line.", "Another line." });

        --- b { font-weight: normal; }

        G Offline
        G Offline
        gus_br
        wrote on last edited by
        #3

        alright, could you please explain these lines? :P comments are fundamental...

        G 1 Reply Last reply
        0
        • G gus_br

          alright, could you please explain these lines? :P comments are fundamental...

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          What is it that you don't understand? It's a method that accepts an array of strings as parameter, and it's a call to the method that creates an array of strings.

          --- b { font-weight: normal; }

          G 1 Reply Last reply
          0
          • G Guffa

            What is it that you don't understand? It's a method that accepts an array of strings as parameter, and it's a call to the method that creates an array of strings.

            --- b { font-weight: normal; }

            G Offline
            G Offline
            gus_br
            wrote on last edited by
            #5

            hmm.. it sounds clearly now... :]

            1 Reply Last reply
            0
            • G Guffa

              public void DoSomething(string[] values) {
              foreach (string value in values) {
              Console.WriteLine(value);
              }
              }

              DoSomething(new string[] { "A text line.", "Another line." });

              --- b { font-weight: normal; }

              P Offline
              P Offline
              premkamalg
              wrote on last edited by
              #6

              hi i have one array in one function . that array i want send other function. how can i send that array plz modify the code i am new to programming. in runtime iam getting that array . DoSomething(new string[] { "A text line.", "Another line." });

              Hi, Thanks, if u think it's good. otherwise sorry.

              G 1 Reply Last reply
              0
              • P premkamalg

                hi i have one array in one function . that array i want send other function. how can i send that array plz modify the code i am new to programming. in runtime iam getting that array . DoSomething(new string[] { "A text line.", "Another line." });

                Hi, Thanks, if u think it's good. otherwise sorry.

                G Offline
                G Offline
                gus_br
                wrote on last edited by
                #7

                premkamalg wrote:

                DoSomething(new string[] { "A text line.", "Another line." });

                this is just a different way to declare and initialize a string. you could reach the same thing this way: string[] strArr = new string[2]; string[0] = "a text line"; string[1] = "another line"; DoSomething(strArr); clear now?

                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