The easiest suggestion I could make it so split off a space make the first
letter caps, then rejoin adding the space back. This probably isn't the
most performant way to handle this, so don't use this in a tight loop, but
it does show some of the built in string functions and char arrays.
bill
string s = "hello world, dot net rocks!";
string [] sa = s.Split( ' ' );
string word = null;
for( int i = 0 ; i < sa.Length ; i++ )
{
word = sa[i];
char [] letters = word.ToCharArray();
if ( letters.Length > 0 )
{
letters[0] = Char.ToUpper( letters[0] );
}
word = new string( letters );
sa[i] = word;
}
s = String.Join( " ", sa );
Console.Write( s );
"JrMc" <Jr**@discussions.microsoft.com> wrote in message
news:9E**********************************@microsof t.com...
I am new to this .net environement. I'm needing to do a simple task - I
need to read the first character of a word and replace it with an
uppercase. Example:
"horse" --> change to "Horse"
I can do this on an as/400 using RPG, but cannot figure out the syntax to
do it in .net with the .substring and .toupper methods.
--
All replies are appreciated.
Thanks in advance.
JrMc