Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# make first letter uppercase

        System.Console.WriteLine(char.ToUpper(str[0]) + str.Substring(1));
Comment

capitalize first letter c#

using static System.Globalization.CultureInfo;
var str = CurrentCulture.TextInfo.ToTitleCase(sortColumn.ToLower().Trim());
Comment

first letter uppercase c#

// first letter of string
private string CapitalizeFirst (string input) {
  	char.ToUpper(myString[0]) + myString[1..]; // captalizes first letter
}

// first letter of each word
private string CapitalizeAll (string input) {
  	var words = input.Split(' '); // create array of words

  	// loop through all words and capitalize them
	for (int i = 0; i < words.length; i++) {
     	words[i] = CapitalizeFirst (words[i]);
    }
  
  	return string.Join(' ', words);
}

string myString = "hello world";

// results
CapitalizeFirst(myString); // "Hello world"
CapitalizeAll(myString); // "Hello World"
Comment

first sentence letter capital in c#

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();
    }
}
Comment

c# capitalize first letter of each word

public static class Capitalize
{
  public static string Word(string input)
  {
    if (string.IsNullOrEmpty(input))
    {
      return string.Empty;
    }
    var a = input.ToCharArray();
    a[0] = char.ToUpper(a[0]);
    for (var i = 1; i < a.Length; i++)
    {
      a[i] = char.ToLower(a[i]);
    }
    return new string(a);
  }

  public static string Sentence(string input)
  {
    return string.Join(" ", input.Split(' ').Select(Word));
  }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: making a gui that can only be visible by owner roblox 
Csharp :: how to create a list in c# unity 
Csharp :: c# datetime remove time 
Csharp :: unity chat system 
Csharp :: httppostedfilebase in .net core 3.1 
Csharp :: c# letters only 
Csharp :: maximize window c# console 
Csharp :: Find an item in a list by LINQ 
Csharp :: how to change a string variables value c# 
Csharp :: how to make a car in unity 
Csharp :: asking for user input integer c# 
Csharp :: how to add ground Check in unity 3d 
Csharp :: how to make an object move in unity 
Csharp :: excel which style property define background color in c# 
Csharp :: unity find gameobject 
Csharp :: c# minus days from datetime 
Csharp :: how to print using C# 
Csharp :: c# list tuple 
Csharp :: unity log error 
Csharp :: where did mark twain go to school 
Csharp :: get last 4 character c# 
Csharp :: get description from enum c# 
Csharp :: c# windows forms print 
Csharp :: how to get integer value from textbox in c# 
Csharp :: decimal c# 2 digits 
Csharp :: unity actions 
Csharp :: index of item in list C# 
Csharp :: jagged array c# 
Csharp :: c# iterate enum 
Csharp :: unity ihandler click right button 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =