I've string in this format '9570 FIELDS STREET RD'
but i need to convert that into '9570 Fields Street Rd' i.e, the first letter in each word will be capital and mostly the first word is integer.
any help
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 9, 2012, 8:44 AM
Satyapriya NayakPosted Jan 9, 2012, 9:21 AM
Try this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show(UppercaseFirst("9570 FIELDS STREET RD"));
}
public string UppercaseFirst(string s)
{
StringBuilder sb = new StringBuilder(s.Length);
bool capitalize = true;
foreach (char c in s)
{
sb.Append(capitalize ? Char.ToUpper(c) : Char.ToLower(c));
capitalize = !Char.IsLetter(c);
}
return sb.ToString();
}
}
}
Thanks