Method instance: Output an array of strings as the form of a | split, such as "Messi | kaka | jong"
static void Main (string[] args) { string[] Strarray = {"Messi", "Kaka", "Cristiano Ronaldo"}; Oper (Strarray); Console.readkey (); } static void Oper (string[] strs) { string resoult = string. Empty; for (int i = 0; i < STRs. Length-1; i++) { Resoult + = Strs[i] + "|"; } Resoult + = Strs[strs. LENGTH-1]; Console.WriteLine (Resoult); }
Users can only enter a number between 0 and 100 to write a method, otherwise the hint out of range
static void Main (string[] args) { Say (); Console.readkey (); } static void Say () { while (true) { Console.WriteLine ("Please enter a number between 1-100"); int num = Convert.ToInt32 (Console.ReadLine ()); if (num < 1 | | num > +) { Console.WriteLine ("Input out of range! Please re-enter "); Continue;}}}
C # methods