|
 |
aspx thread: Does anyone have a Capitalize function in C#?
Message #1 by info@e... on Wed, 17 Apr 2002 09:21:09
|
|
Hello,
I want to know if anyone has a already made C# function to capitalize the
first word of every sentence. I have it in classic ASP but I don't want to
re-invent the wheel and create one in ASP.net. I figured someone might
already have one since they are very common. You would think .Net would
have something built in. Does it have one? If so, I would like some
reference.
FYI: A capitalize function should make all letters lowercase except for
the first letter of every sentence.
Thanks in advance!
- Elmer M.
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 17 Apr 2002 08:33:52 -0700
|
|
Elmer,
function CapitalizeFirstWord(string MyWord) {
return MyWord[0].ToUpper() + MyWord[1].ToLower();
}
I haven't compiled this myself, but this should give you a start.
Minh.
-----Original Message-----
From: info@e... [mailto:info@e...]
Sent: Wednesday, April 17, 2002 9:21 AM
To: ASP+
Subject: [aspx] Does anyone have a Capitalize function in C#?
Hello,
I want to know if anyone has a already made C# function to capitalize
the
first word of every sentence. I have it in classic ASP but I don't want
to
re-invent the wheel and create one in ASP.net. I figured someone might
already have one since they are very common. You would think .Net would
have something built in. Does it have one? If so, I would like some
reference.
FYI: A capitalize function should make all letters lowercase except for
the first letter of every sentence.
Thanks in advance!
- Elmer M.
Message #3 by Sridhar Raj G <Sridharr@i...> on Wed, 17 Apr 2002 21:17:20 +0530
|
|
Try this
This function i wrote to make all words in a string to have first word as
capital
public void btnFormatString_OnClick(Object Sender, EventArgs e){
//variable declarations
string strSearch = "your string goes here"
int iLStrList = 0;
string strPCString;
string strFormatString="";
string[] strList = strSearch.Split(' ');
foreach(string sL in strList){
if(sL!=""){
strPCString
sL.Substring(0,1).ToUpper().Trim()+
sL.Substring(1,sL.Length-1).ToLower().Trim();
strFormatString
strFormatString + strPCString + " ";
}
iLStrList = iLStrList+1;
if(iLStrList==strList.Length){
Response.Write(strFormatString);
}
}
}
Regards
Sridahr G
http://www.icode.com
-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Wednesday, April 17, 2002 9:04 PM
To: ASP+
Subject: [aspx] RE: Does anyone have a Capitalize function in C#?
Elmer,
function CapitalizeFirstWord(string MyWord) {
return MyWord[0].ToUpper() + MyWord[1].ToLower();
}
I haven't compiled this myself, but this should give you a start.
Minh.
-----Original Message-----
From: info@e... [mailto:info@e...]
Sent: Wednesday, April 17, 2002 9:21 AM
To: ASP+
Subject: [aspx] Does anyone have a Capitalize function in C#?
Hello,
I want to know if anyone has a already made C# function to capitalize
the
first word of every sentence. I have it in classic ASP but I don't want
to
re-invent the wheel and create one in ASP.net. I figured someone might
already have one since they are very common. You would think .Net would
have something built in. Does it have one? If so, I would like some
reference.
FYI: A capitalize function should make all letters lowercase except for
the first letter of every sentence.
Thanks in advance!
- Elmer M.
Message #4 by info@e... on Sat, 20 Apr 2002 23:27:14
|
|
Thanks Sridahr,
Your function works great. I got it to work on the first try.
- Elmer M.
> Try this
This function i wrote to make all words in a string to have first word as
capital
public void btnFormatString_OnClick(Object Sender, EventArgs e){
//variable declarations
string strSearch = "your string goes here"
int iLStrList = 0;
string strPCString;
string strFormatString="";
string[] strList = strSearch.Split(' ');
foreach(string sL in strList){
if(sL!=""){
strPCString
sL.Substring(0,1).ToUpper().Trim()+
sL.Substring(1,sL.Length-1).ToLower().Trim();
strFormatString
strFormatString + strPCString + " ";
}
iLStrList = iLStrList+1;
if(iLStrList==strList.Length){
Response.Write(strFormatString);
}
}
}
Regards
Sridahr G
http://www.icode.com
-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Wednesday, April 17, 2002 9:04 PM
To: ASP+
Subject: [aspx] RE: Does anyone have a Capitalize function in C#?
Elmer,
function CapitalizeFirstWord(string MyWord) {
return MyWord[0].ToUpper() + MyWord[1].ToLower();
}
I haven't compiled this myself, but this should give you a start.
Minh.
-----Original Message-----
From: info@e... [mailto:info@e...]
Sent: Wednesday, April 17, 2002 9:21 AM
To: ASP+
Subject: [aspx] Does anyone have a Capitalize function in C#?
Hello,
I want to know if anyone has a already made C# function to capitalize
the
first word of every sentence. I have it in classic ASP but I don't want
to
re-invent the wheel and create one in ASP.net. I figured someone might
already have one since they are very common. You would think .Net would
have something built in. Does it have one? If so, I would like some
reference.
FYI: A capitalize function should make all letters lowercase except for
the first letter of every sentence.
Thanks in advance!
- Elmer M.
|
|
 |