Hello friend
I have code name and surname put into same string with coma in the middle ,as "JohnSmith"
I need to insert into database to separate
Can you show me how to code that please.
Thanks
vijay
Hello friend
I have code name and surname put into same string with coma in the middle ,as "JohnSmith"
I need to insert into database to separate
Can you show me how to code that please.
Thanks
vijay
Presumably your asking how to split up a single string where the names are seperated by a comma ','
If that's the case, you can split a string using the Split(char x)
method.
Then you can use each part what ever way you want.
string x = "John,Smith";
string [] parts = x.Split(',');
if(parts.Length == 2)
{
string firstName = parts[0];
string secondName = parts[1];
}
Something like that.
Vijay, how about at least trying to google stuff like this by yourself? As in "C# split string"? Hundreds of decent results come up. Heck, there are tons of these examples on SO as well.
Other people can't do your work for you, so how about actually putting in some effort into learning process instead of relying on others to do mundane things for you?
This is easy in most cases, but in a production environment the edge cases kill you. I like the string.split answer, but the incredible variation in how names are formated means more thinking and more code.