c# capitalize first letter
C#
string text = "john smith";
// "John smith"
string firstLetterOfString = text.Substring(0, 1).ToUpper() + text.Substring(1);
// "John Smith"
// Requires Linq! using System.Linq;
string firstLetterOfEachWord =
string.Join(" ", text.Split(' ').ToList()
.ConvertAll(word =>
word.Substring(0, 1).ToUpper() + word.Substring(1)
)
);public static class StringExtension
{
public static string CapitalizeFirst(this string s)
{
bool IsNewSentense = true;
var result = new StringBuilder(s.Length);
for (int i = 0; i < s.Length; i++)
{
if (IsNewSentense && char.IsLetter(s[i]))
{
result.Append (char.ToUpper (s[i]));
IsNewSentense = false;
}
else
result.Append (s[i]);
if (s[i] == '!' || s[i] == '?' || s[i] == '.')
{
IsNewSentense = true;
}
}
return result.ToString();
}
}
Also in C#:
- Title
- sort datatable c#
- Category
- C#
- Title
- onmouseover unity
- Category
- C#
- Title
- check if current time is in the morning c#
- Category
- C#
- Title
- south african id number validation c#
- Category
- C#
- Title
- how to create more accurate searching c#
- Category
- C#
- Title
- 2d object look at object
- Category
- C#
- Title
- c# ienumerable to list
- Category
- C#
- Title
- odbc command parameters c#
- Category
- C#
- Title
- c# expression func automatically select return type
- Category
- C#
- Title
- unity change text color
- Category
- C#
- Title
- c# read a webpage data
- Category
- C#
- Title
- unity access child
- Category
- C#
- Title
- asp.net mvc return file
- Category
- C#
- Title
- c# remove last value from list
- Category
- C#
- Title
- c# input integer
- Category
- C#
- Title
- how to populate listbox using list<t> c#
- Category
- C#
- Title
- unity vector3 to array
- Category
- C#
- Title
- unity c# write line
- Category
- C#
- Title
- c# xml file builder
- Category
- C#
- Title
- unity input get axis
- Category
- C#
- Title
- bulk update in c# using jquery datatble
- Category
- C#
- Title
- enums c#
- Category
- C#
- Title
- try catch c#
- Category
- C#
- Title
- iteration c#
- Category
- C#
- Title
- 2d character controller unity
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- c# list remove item based on property duplicate
- Category
- C#
- Title
- message uwp c#
- Category
- C#
- Title
- math.pow in C# using loop
- Category
- C#
- Title
- unity onselect gizmos wireframe
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- unity deactivate scripts in list
- Category
- C#
- Title
- xamarin hide back button
- Category
- C#
- Title
- c# how to refreshyour bindingsource
- Category
- C#
- Title
- how to declare a string c#
- Category
- C#
- Title
- c# EncoderParameter
- Category
- C#
- Title
- mailkit send attachment
- Category
- C#
- Title
- initialise icollection c#
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- unity rigidbody constraints
- Category
- C#
- Title
- c# contextswitchdeadlock
- Category
- C#
- Title
- viewBag as a list
- Category
- C#
- Title
- c# get current directory xamarin
- Category
- C#
- Title
- How do i destroy a prefab without the error?
- Category
- C#
- Title
- unity c# foreach
- Category
- C#
- Title
- unity on trigger enter
- Category
- C#
- Title
- move towards target unity
- Category
- C#
- Title
- isprime c#
- Category
- C#
- Title
- using mediamanager how to play mp3 files
- Category
- C#
- Title
- if a method doesnt rutern a value, what shouyld i reeturn c#
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- c# instantiate
- Category
- C#
- Title
- attribute usage c#
- Category
- C#
- Title
- https request c#
- Category
- C#
- Title
- how to pause physics in unity c#
- Category
- C#
- Title
- transform object according to its parent unity
- Category
- C#
- Title
- unity how to make jump script
- Category
- C#
- Title
- get random point within radius
- Category
- C#
- Title
- unity rb.addexplosionforce 2d
- Category
- C#
- Title
- cannot apply indexing with to an expression of type 'object'
- Category
- C#
- Title
- Failed to retrieve Firebase Instance Id
- Category
- C#
- Title
- how to add an embedded resource in visual studio code
- Category
- C#
- Title
- Rigidbody.addforce
- Category
- C#
- Title
- convert string to datetime c#
- Category
- C#
- Title
- c# keyboard enter
- Category
- C#
- Title
- what is a protected int c#
- Category
- C#
- Title
- .net identity seed users and roles
- Category
- C#
- Title
- change sprite of gameobject unity
- Category
- C#
- Title
- autofixture ignore property
- Category
- C#
- Title
- c# how to use inovke
- Category
- C#
- Title
- c# dynamic object get value
- Category
- C#
- Title
- unity get data from firebase
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- combine two arraylist c#
- Category
- C#
- Title
- unity how to get y value
- Category
- C#
- Title
- how to get odd saturday in a month in c#
- Category
- C#
- Title
- read configuration workerservice
- Category
- C#
- Title
- convert string to boolean c#
- Category
- C#
- Title
- onmouseclick unity
- Category
- C#
- Title
- how to put double quotes in a string c#
- Category
- C#
- Title
- how to crouch in unity
- Category
- C#
- Title
- c sharp add item to dictionary
- Category
- C#
- Title
- Move player on planets in unity 2d
- Category
- C#
- Title
- C# previous method
- Category
- C#
- Title
- date time heutiges datum
- Category
- C#
- Title
- c# polymorphism
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- c# index in select
- Category
- C#
- Title
- add getenumerator to class c#
- Category
- C#
- Title
- how to mock abstract httpcontext using moq .net core
- Category
- C#
- Title
- webutility.urlencode space
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- how to cast list to observablecollection c#
- Category
- C#
- Title
- disable a component unity
- Category
- C#
- Title
- whats a string
- Category
- C#
- Title
- c# convert column name to number
- Category
- C#
- Title
- c# convert Unix time in seconds to datetime
- Category
- C#
- Title
- c# string list contains
- Category
- C#
- Title
- debug.log unity
- Category
- C#
- Title
- c# inline initialize dictionary
- Category
- C#