PDA

View Full Version : سوال:درموردآرایه



nazanintaraneh
چهارشنبه 20 شهریور 1387, 11:40 صبح
برنامه ای که بتواند اعدادی را که در یک textbox با کاما ازهم جداشده اند را در یک آرایه نشان دهد.

علیرضا مداح
چهارشنبه 20 شهریور 1387, 12:45 عصر
سلام دوست عزیز،
باید از متد Split مربوط به کلاس System.String استفاده نمایید ،/
مثالی از MSDN :


using System;
public class SplitTest {
public static void Main() {
string words = "This is a list of words, with: a bit of punctuation.";
string [] split = words.Split(new Char [] {' ', ',', '.', ':'});
foreach (string s in split) {
if (s.Trim() != "")
Console.WriteLine(s);
}
}
}
// The example displays the following output to the console:
// This
// is
// a
// list
// of
// words
// with
// a
// bit
// of
// punctuation