In C#, using the initialization syntax I can say:
string[] mystrings = {"one", "two", "three"};
Is it possible to use the same array initialization syntax to convert this:
string test = "This is a good sentance to split, it has at least one split word to split on.";
string[] mystrings = test.Split(new string[] { "split" }, StringSplitOptions.RemoveEmptyEntries);
Into something like this:
string test = "This is a good sentance to split, it has at least one split word to split on.";
string[] mystrings = test.Split({ "split" }, StringSplitOptions.RemoveEmptyEntries);
It seems like it should work but I can't get it to do anything.
Almost there:
string[] mystrings = test.Split(new[]{ "split" },
StringSplitOptions.RemoveEmptyEntries);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With