Link to home
Start Free TrialLog in
Avatar of kwh3856
kwh3856Flag for United States of America

asked on

C# Formatting Text - Address data

I am reading data from a table and the data from the address field varies on its format.  I would like to standardize on the format of ####  Upper Case first letter of the address and lower case all other characters.  But if there is a second word in the address I would like to upper case that word also.  What would the be the C# syntax to accomplish this task?

string address;


address.Upper(); ??????????????

Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

create a function implementing these logic

1. you need to split address data by space.
2. loop through each splitted word and make it first caps

since I'm from mobils, I can only guide u

something like this.

string address = "street no. 12, place"';
string add() = address.Split(" ");
address = "";

for(int I = 0; I<=add.Length()-1; I++)
{
address += String.Left(add(i), 1).ToUpper() + String.Right(add(i).Length()-1) + " ";
}

if any syntax error pplz correct it.

typed from phone using stylus - not tested
ASKER CERTIFIED SOLUTION
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwh3856

ASKER

WOW from you phone...AWESOME!!!!


Thanks
Kenny
nice to help you!

In bus now to my native :)

Raj