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. How can i use infinite parameters in a method

How can i use infinite parameters in a method

Scheduled Pinned Locked Moved C#
helpquestioncsharpc++learning
2 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.
  • D Offline
    D Offline
    da vinci coder
    wrote on last edited by
    #1

    ok my problem is like this.. i want to make a method for clearing textbox`s in a form and the method looks like this.. public void clearTextBox(TextBox a, TextBox b) { a.Text=""; b.Text=""; } of course it will clear only two textbox`s which i decleared.. but i want my method to clear n textbox so i can use this method several times.. how should the code look like ? i remember from c++ it should be something like this but its not working at c#: public void clearTextBox(TextBox a,...,Textbox b); any help would be great.. thanx guys.. good coding..

    D 1 Reply Last reply
    0
    • D da vinci coder

      ok my problem is like this.. i want to make a method for clearing textbox`s in a form and the method looks like this.. public void clearTextBox(TextBox a, TextBox b) { a.Text=""; b.Text=""; } of course it will clear only two textbox`s which i decleared.. but i want my method to clear n textbox so i can use this method several times.. how should the code look like ? i remember from c++ it should be something like this but its not working at c#: public void clearTextBox(TextBox a,...,Textbox b); any help would be great.. thanx guys.. good coding..

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

      void ClearText(params Textbox[] text)
      {
      foreach (Textbox t in text)
      t.Text = "";
      }

      Then, you can call it with any number of arguments: ClearText(TextBox1, TextBox2, TextBox3); I don't see dead pixels anymore... Yes, even I am blogging now! -- modified at 6:59 Saturday 12th November, 2005

      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