Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array.
Overload List:
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function Split(ParamArray Char()) As String()
[C#] public string[] Split(params char[]);
[C++] public: String* Split(__wchar_t __gc[]) __gc[];
[JScript] public function Split(Char[]) : String[];
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array. A parameter specifies the maximum number of array elements to return.
[Visual Basic] Overloads Public Function Split(Char(), Integer) As String()
[C#] public string[] Split(char[], int);
[C++] public: String* Split(__wchar_t __gc[], int) __gc[];
[JScript] public function Split(Char[], int) : String[];
The string Split() and Join() methods provide functionality to work with delimited strings. The Split() method allows you to gather a delimited set of values from a string into an array and the Join() method lets you create a delimited string from an array. This supports both custom data formats as well as information interchange with other programs.
using System;
namespace ASPcsharp
{
class StringJoinSplitExample
{
static void Main(string[] args)
{
// comma delimited string
string commaDelimitedExample = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
Console.WriteLine("Original Comma Delimited String: \n{0}\n", commaDelimitedExample);
// separate individual items between commas
string[] year = commaDelimitedExample.Split(new char[] {','});
Console.WriteLine("Each individual item: ");
foreach(string month in year)
{
Console.Write("{0} ", month);
}
Console.WriteLine("\n");
// combine array elements with a new separator
string colonDelimeted = String.Join(":", year);
Console.WriteLine("New Colon Delimited String: \n{0}\n", colonDelimeted);
string[] quarter = commaDelimitedExample.Split(new Char[] {','}, 3);
Console.WriteLine("The First Three Items: ");
foreach(string month in quarter)
{
Console.Write("{0} ", month);
}
Console.WriteLine("\n");
string thirdQuarter = String.Join("/", year, 6, 3);
Console.WriteLine("The Third Quarter: \n{0}\n", thirdQuarter);
}
}
}
Overload List:
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function Split(ParamArray Char()) As String()
[C#] public string[] Split(params char[]);
[C++] public: String* Split(__wchar_t __gc[]) __gc[];
[JScript] public function Split(Char[]) : String[];
Identifies the substrings in this instance that are delimited by one or more characters specified in an array, then places the substrings into a String array. A parameter specifies the maximum number of array elements to return.
[Visual Basic] Overloads Public Function Split(Char(), Integer) As String()
[C#] public string[] Split(char[], int);
[C++] public: String* Split(__wchar_t __gc[], int) __gc[];
[JScript] public function Split(Char[], int) : String[];
The string Split() and Join() methods provide functionality to work with delimited strings. The Split() method allows you to gather a delimited set of values from a string into an array and the Join() method lets you create a delimited string from an array. This supports both custom data formats as well as information interchange with other programs.
using System;
namespace ASPcsharp
{
class StringJoinSplitExample
{
static void Main(string[] args)
{
// comma delimited string
string commaDelimitedExample = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
Console.WriteLine("Original Comma Delimited String: \n{0}\n", commaDelimitedExample);
// separate individual items between commas
string[] year = commaDelimitedExample.Split(new char[] {','});
Console.WriteLine("Each individual item: ");
foreach(string month in year)
{
Console.Write("{0} ", month);
}
Console.WriteLine("\n");
// combine array elements with a new separator
string colonDelimeted = String.Join(":", year);
Console.WriteLine("New Colon Delimited String: \n{0}\n", colonDelimeted);
string[] quarter = commaDelimitedExample.Split(new Char[] {','}, 3);
Console.WriteLine("The First Three Items: ");
foreach(string month in quarter)
{
Console.Write("{0} ", month);
}
Console.WriteLine("\n");
string thirdQuarter = String.Join("/", year, 6, 3);
Console.WriteLine("The Third Quarter: \n{0}\n", thirdQuarter);
}
}
}