Reputation: 3101
I have following string value: AnnualFee[[ContactNeeYear
that I want to split using separator : "[["
The MSDN topic String.Split says that such function exists, so i used following code :
oMatch.Groups[0].Value.Split('[[');
but it throws an error saying:
Can not implicitly convert string[] to string
so how to split string value with separator : "[["
Upvotes: 3
Views: 357
Reputation: 6105
In a short way ,
string yourString = "AnnualFee[[ContactNeeYear";
string [] _split = yourString.Split(new string[] { "[[" }, StringSplitOptions.None);
Upvotes: 0
Reputation: 3860
Try below code, it has worked for me:
string abc = "AnnualFee[[ContactNeeYear";
string[] separator = { "[[" };
string[] splitedValues = abc.Split(separator , StringSplitOptions.None);
I hope it will help you.. :):)
Upvotes: 4
Reputation: 26635
string text= "AnnualFee[[ContactNeeYear";
string[] parts= Regex.Split(text, @"\[\[");
The result is:
AnnualFee
ContactNeeYear
You can use Regex.Split(text, pattern) for such purpose.
Upvotes: 2