String stringToSplit = "hello#World#How#Are#You";
string[] tokens = stringToSplit.Split('#');


绝对好。

但是我怎么能从中得到“安贾利”

String stringToSplit = "hello 'Anjali', How Are You";
string[] tokens = stringToSplit.Split(' '); // What to put Here as it doesnt take ' character

最佳答案

您可以使用正则表达式执行此操作

var tokens = Regex.Split(stringToSplit, @"'", RegexOptions.None);

09-08 08:50