Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-2006, 02:04 PM
Chan Chan is offline
Programming Professional
 
Join Date: Jun 2006
Posts: 204
Credits: 1
Rep Power: 10
Chan is on a distinguished road
Default Cap only first letter

Is there a function or a way to only make the first letter of a word cap?

Like:

Code:
CODE or code (becomes) Code;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-16-2006, 08:36 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

I would say whatever string you have, split it into two strings, the first letter being one string, and the rest of the word being the second string, then use the toupper and tolower functions on each of them to get the desired case, then put the string back together in one string.

string myString
string 1 = myString.firstletter
string 2 = myString.therest
1.toupper
2.tolower
myString = 1 + 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-16-2006, 07:52 PM
Void's Avatar   
Void Void is offline
Programming Expert
 
Join Date: Jun 2006
Posts: 410
Credits: 0
Rep Power: 11
Void is on a distinguished road
Default

Not too hard and basically just what hooser said.

Code:
  string upper = textBox1.Text.Substring(0,1).ToUpper();
  string lower = textBox1.Text.Substring(1).ToLower();

  string complete = String.Concat(upper, lower);
Replace textbox.text with your own string.
__________________
Void
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-16-2006, 10:07 PM
brackett brackett is offline
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 10
brackett is on a distinguished road
Default

Or, you could use the (ghast!) Microsoft.VisualBasic.Strings.StrConv function with VbStrConv.ProperCase. That'll capitalize every word in your string.

As Billy Hollis says, it was very nice of the VB community to let us use their new framework from other languages.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-17-2006, 07:44 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

I didnt know one could use VB functions in C# code... Thanks for the post brackett
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-19-2006, 05:46 PM
Ronin Ronin is offline
Programming Professional
 
Join Date: Apr 2006
Posts: 299
Credits: 3
Rep Power: 10
Ronin is on a distinguished road
Default

Hey, that is pretty cool. I didn't even know VB had a function that did this to start with. haha, I guess you have to know all the functions in .NET - but how do you go about learning them???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 03:22 PM
Java:Tutorial - Tic-Tac-Toe John Java Tutorials 25 02-27-2008 06:41 PM
vB Weekly Stats Version 1.7 Jordan Community Projects 51 02-11-2008 11:25 AM
get fast cash? Deathcry Business and Legal 5 06-18-2007 09:39 AM


All times are GMT -5. The time now is 08:08 PM.

Contest Stats

Xav ........ 1322.18
MeTh0Dz|Reb0rn ........ 1053.7
morefood2001 ........ 879.43
John ........ 877.37
marwex89 ........ 869.98
WingedPanther ........ 830.24
Brandon W ........ 735.07
chili5 ........ 309.39
Steve.L ........ 236.23
dcs ........ 216.02

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads