ITsolutionWizard
asked on
c# string
I have a name John Smith
and I want to have format as jsmith
How can I do that in c#?
Thanks
and I want to have format as jsmith
How can I do that in c#?
Thanks
ASKER
sorry not working
Let me check it again..
//Your code goes here
String str = "John Smith";
String newstr = str.Substring(0,1) + str.Substring(str.Length-s tr.IndexOf (' ')-1);
Console.WriteLine (newstr);
Ouput
JSmith
String str = "John Smith";
String newstr = str.Substring(0,1) + str.Substring(str.Length-s
Console.WriteLine (newstr);
Ouput
JSmith
using System;
namespace rr_28975164
{
class Program
{
static void Main(string[] args)
{
string Fullname = "John Smith";
string result;
string first;
string last;
string[] names = Fullname.Split(' ');
first = names[0][0].ToString();
last = names[1];
string output = first + last;
Console.WriteLine(output);
Console.ReadLine();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
STRING str = "John Smith"
String newstr = SUBSTRING (str,1) + SUBSTRING(str,INDEXOF(' '), LEN(str) - INDEXOF(' ') )