本文整理汇总了C#中System.String.Split方法的典型用法代码示例。如果您正苦于以下问题:C# String.Split方法的具体用法?C# String.Split怎么用?C# String.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.Split方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkPathValid
public static Boolean checkPathValid(String path)
{
while (true)
{
String[] pathes = path.Split('/');
if (!"".Equals(pathes[0]))
{
return false;
}
path = path.Substring(1);
pathes = path.Split('/');
if (!Regex.IsMatch(pathes[0], regexpPathName))
{
return false;
}
if (path.IndexOf("/") < 0)
{
return true;
}
path = path.Substring(path.IndexOf("/"));
}
}
示例2: TimeStamp
public TimeStamp(String str)
{
try
{
String[] args = str.Split(':');
if (args.Length <= 2)
{
int mm = int.Parse(str.Split(':')[0]);
int ss = int.Parse(str.Split(':')[1]);
this.Hours = 0;
this.Minutes = mm;
this.Seconds = ss;
}
else
{
int hh = int.Parse(args[0]);
int mm = int.Parse(args[1]);
int ss = int.Parse(args[2]);
this.Hours = hh;
this.Minutes = mm;
this.Seconds = ss;
}
}
catch (Exception e)
{
this.Hours = 0;
this.Minutes = 0;
this.Seconds = 0;
}
}
示例3: DocDbFormatIPC
//返回IPC中/前的所有字符串加/后的4个字符
public static String DocDbFormatIPC(String ipc)
{
if (ipc.Trim() == "")
{
return ipc.Trim();
}
else if (!ipc.Contains('/'))
{
return ipc.Split(' ')[0].Trim();
}
else
{
String[] tem = ipc.Split('/');
String result = ipc.Split('/')[0].Trim() + "/";
if (tem[1].Length > 4)//只取/后的4个字符
{
result = result + tem[1].Substring(0, 4).Trim();
}
else
{
result = result + tem[1].Trim();
}
return result;
}
}
示例4: Tape
public Tape(String initialiser)
{
mSymbols = new List<char>();
String[] initialiserLines = initialiser.Split('\n');
foreach (String character in initialiserLines[0].Split(','))
{
if(String.IsNullOrEmpty(character))
{
mSymbols.Add(' ');
}
else
{
mSymbols.Add(character[0]);
}
}
mIndex = 0;
if (initialiserLines.Length > 1)
{
string headPosition = initialiser.Split('\n')[1];
if (!String.IsNullOrEmpty(headPosition))
{
mIndex = Int32.Parse(headPosition);
}
}
}
示例5: ProcessAnswer
public void ProcessAnswer(String nick, String fullmessage, String[] message, int size)
{
if (message[3][0] == ':') message[3] = message[3].Substring(1);
bool isChannel = message[2][0] == '#';
if (isChannel)
{
try
{
((ITrigger)ChannelTriggers[message[3]]).ProcessTrigger(nick,message[2],fullmessage,message,size);
}
catch (NullReferenceException nre)
{
}
Bot.Display.WriteLine('[' + message[2] + ']' + '\t' + '<' + nick + '>' + ' ' + fullmessage.Split(separator, 4)[3].Substring(1));
}
else
{
try
{
((ITrigger)ChannelTriggers[message[3]]).ProcessTrigger(nick, message[2], fullmessage, message, size);
}
catch (NullReferenceException nre)
{
}
Bot.Display.WriteLine('[' + "PM" + ']' + ' ' + '<' + nick + '>' + ' ' + fullmessage.Split(separator, 4)[3].Substring(1), ConsoleColor.DarkMagenta, ConsoleColor.DarkGray);
}
}
示例6: AddNewArtist
public PerformerModel AddNewArtist(String artistName)
{
var dsInsert = new DataSet();
var insertQuery = String.Format("Insert Into Performers (FirstName, LastName, ShortName) Values ('{0}', '{1}', '{0} {1}') Select @@Identity", artistName.Split(' ')[0], artistName.Split(' ')[1]);
using (var insertCommand = new SqlCommand(insertQuery, WingtipTicketApp.CreateTenantSqlConnection()))
{
using (var insertData = new SqlDataAdapter(insertCommand))
{
insertData.Fill(dsInsert);
if (dsInsert.Tables.Count > 0 && dsInsert.Tables[0].Rows.Count > 0 && dsInsert.Tables[0].Rows[0][0] != DBNull.Value)
{
return new PerformerModel
{
PerformerId = Int32.Parse(dsInsert.Tables[0].Rows[0][0].ToString()),
ShortName = artistName,
FirstName = artistName.Split(' ')[0],
LastName = artistName.Split(' ')[1]
};
}
}
}
return null;
}
示例7: IPIStringtoList
public static List<string> IPIStringtoList(String str)
{
str.Split(new char[] { ';' });
List<String> Res = new List<string>();
Res.AddRange(str.Split(new char[] { ';' }));
return Res;
}
示例8: findPoint
// First Mathematical challenger
public static string findPoint(String input)
{
TextReader reader = Console.In;
StringBuilder vs_result = new StringBuilder();
if (!input.Equals(string.Empty))
input = reader.ReadToEnd();
int numberOfTests = Convert.ToInt32(input.Split('\n')[0]);
String line = string.Empty;
int xFinalPoint = 0;
int y1FinalPoint = 0;
List<int[]> lst_Matrix = new List<int[]>();
for (int i = 1; i <= numberOfTests; i++)
{
line = input.Split('\n')[i];
int[] pointP = { Convert.ToInt32(line.Split(' ')[0]), Convert.ToInt32(line.Split(' ')[1]) };
int[] pointQ = { Convert.ToInt32(line.Split(' ')[2]), Convert.ToInt32(line.Split(' ')[3]) };
xFinalPoint = (pointQ[0] * 2) - pointP[0];
y1FinalPoint = (pointQ[1] * 2) - pointP[1];
int[] matrixResult = { xFinalPoint, y1FinalPoint };
lst_Matrix.Add(matrixResult);
}
int[] vector;
for (int i = 0; i < lst_Matrix.Count; i++)
{
vector = lst_Matrix[i];
vs_result.Append(string.Format("{0} {1}", vector[0], vector[1]));
if ((i + 1) < lst_Matrix.Count)
vs_result.Append("\n");
}
return vs_result.ToString();
}
示例9: TimerDayAndTimeCheck
private Boolean TimerDayAndTimeCheck(String SettingNameDaysofWeek, String SettingNameHours,String SettingDays)
{
DateTime _CurrentTime = DateTime.Now;
String strDaysofWeek, strHours,strDays;
try
{
strDaysofWeek = SettingNameDaysofWeek;
strHours = SettingNameHours;
strDays = SettingDays;
Boolean k;
k = strHours.Split(',').Select(i => Convert.ToString(i)).ToList().Contains(_CurrentTime.Hour.ToString());
if ((strDaysofWeek.Split(',').Select(i => Convert.ToString(i).ToUpper()).ToList().Contains(_CurrentTime.DayOfWeek.ToString().ToUpper()) == true) &&
(strHours.Split(',').Select(i => Convert.ToString(i)).ToList().Contains(_CurrentTime.Hour.ToString()) == true) &&
(strDays.Split(',').Select(i => Convert.ToString(i)).ToList().Contains(_CurrentTime.Day.ToString()) == true)
)
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{ throw e; }
}
示例10: ParseClientInput
public void ParseClientInput(String input)
{
String[] split = input.Split(ssep);
switch (split[0].ToLower())
{
case "/select":
if (split.Length == 2 && split[1][0] == '#') ChangeCurrentChannel(split[1]);
break;
case "/me":
if (CurrentChannel != null & split.Length >= 2) Bot.SendQueue.Add(Message.Action(CurrentChannel, input.Split(ssep,2)[1]));
break;
case "/notice":
if (split.Length >= 3) Bot.SendQueue.Add(Message.Notice(split[1], input.Split(ssep, 3)[2]));
break;
case "/part":
if (split.Length >= 2) Bot.SendQueue.Add("PART " + split[1] + " :leaving");
else if (CurrentChannel != null) Bot.SendQueue.Add("PART " + CurrentChannel + " :leaving");
break;
case "/join":
if (split.Length == 2) Bot.SendQueue.Add("JOIN " + split[1]);
else if (CurrentChannel != null) Bot.SendQueue.Add("JOIN " + CurrentChannel);
break;
default:
if (CurrentChannel != null) Bot.SendQueue.Add(Message.PrivMsg(CurrentChannel, input));
break;
}
}
示例11: interpretCsCode
public static String interpretCsCode(String csCode, PlayList pl, String path_of_cs_file, Dictionary<String, String> vars)
{
String interpreted = "";
String[] split_at_instruction = csCode.Split(';');
foreach (String instruction_set in split_at_instruction)
{
if (instruction_set.Split('(').Length == 2)
{
String instruction = instruction_set.Split('(')[0];
String args_unparsed = instruction_set.Split('(')[1];
String[] args = args_unparsed.Substring(0, args_unparsed.Length - 1).Trim().Split(',');
instruction = instruction.Trim();
String directory = path_of_cs_file.Replace(path_of_cs_file.Split('/')[path_of_cs_file.Split('/').Length - 1], "");
//INSTRUCTIONS: ------------------------------------------------------------------------------------------------------
if (instruction.Equals("genList")) interpreted = genList(pl, directory + args[0].Trim(), args[1].Trim());
else if (instruction.Equals("getVar")) interpreted = vars[args[0].Split('$')[1]];
else continue;
//---------------------------------------------------------------------------------------------------------------------
}
else continue;
}
return interpreted;
}
示例12: EventsLine
public EventsLine(String t, TimeStamp s, TimeStamp e, String lastactor)
{
//not fully implemented. needs to parse original script
if (t[0] == '#')
{
EType = "Comment";
Text = t.Substring(1).Trim();
}
else
{
EType = "Dialogue";
if (t.Contains(':'))
{
char[] acse = { ':' };
Name = t.Split(acse, 2)[0];
Text = t.Split(acse, 2)[1].Trim();
}
else
{
Name = lastactor;
Text = t;
}
}
Layer = 0;
Start = s;
End = e;
Style = "Default";
MarginL = 0;
MarginR = 0;
MarginV = 0;
Effect = "";
}
示例13: GetComponents
public static IEnumerable<IComponent> GetComponents(String fieldRawText, Context context)
{
String[] componentStrings = fieldRawText.Split(context.ComponentSeparator);
return
from item in fieldRawText.Split(context.ComponentSeparator)
select ComponentFactory.GetComponent(item, context);
}
示例14: getDate
private DateTime getDate(String data)
{
String[] day = data.Split(' ')[0].Split('/');
String[] time = data.Split(' ')[1].Split(':');
return new DateTime(int.Parse(day[2]), int.Parse(day[1]), int.Parse(day[0]),
int.Parse(time[0]), int.Parse(time[1]), int.Parse(time[2]));
}
示例15: setOvenTemp
public void setOvenTemp(String oventemp)
{
this.oventemp = int.Parse(oventemp.Split()[3]);
if (Regex.Match(oventemp, "gas mark").Success)
{
String mark = oventemp.Split()[8];
this.gasmark = int.Parse(mark.Substring(0, mark.Length - 1));
}
}