[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

how do i get a substring without predefined length

UserName = John Doe

I just want to retrieve only first name.
0
Meinhoonaa
Asked:
Meinhoonaa
  • 3
1 Solution
 
p_davisCommented:
you can use the split method of the string class and split on the " " (space) and it returns a string array then you can just retrieve the 0 index of the array for the first name
0
 
p_davisCommented:
string[] strArray = UserName .Split(" ");

string firstName = strArray[0];
0
 
MeinhoonaaAuthor Commented:
sample please
0
 
p_davisCommented:
^^

 =)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now