I have string str = "Join Smith hate meat"
.
I want to get JoinSmith
from this str
.
I tried code:
private static string GetFirstWord(string str)
{
return str.Split(' ').Take(2).ToString();
}
This code not working for me.
I tried: return str.Split(' ').FirstOrDefault
it get only first part of string Join
.