Split string at first space and get 2 sub strings in c# -
i have string this
inixa4 agartala inagx4 agatti island
i want split such way inagx4
& agatti island
if using var commands = line.split(' ');
it splits inagx4, agatti, island
if there 4 space give 4 array of data.how can achieve 2 substring
since have 2
space, split(' ')
generates array 3 elements.
based on example, can index of first white space , generate strings substring
based on index.
var s = "inagx4 agatti island"; var firstspaceindex = s.indexof(" "); var firststring = s.substring(0, firstspaceindex); // inagx4 var secondstring = s.substring(firstspaceindex + 1); // agatti island
Comments
Post a Comment