
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Print first letter of each word in a string in C#
Let’s say the string is −
string str = "Never Give Up!";
Firstly, split each word −
string[] strSplit = str.Split();
Now, loop through each word and use the substring method to display the first letter as shown in the following code −
Example
using System; public class Program { public static void Main() { string str = "Never Give Up!"; Console.WriteLine("Initial String= "+str); Console.WriteLine("Displaying first letter of each word..."); string[] strSplit = str.Split(); foreach (string res in strSplit) { Console.Write(res.Substring(0,1)); } } }
Output
Initial String= Never Give Up! Displaying first letter of each word... NGU
- Related Articles
- Print first letter of each word in a string using C# regex
- Getting first letter of each word in a String using regex in Java
- Java Program to Print first letter of each word using regex
- C++ Program to Print first letter of each word using regex
- Golang program to print first letter of each word using regex
- How to capitalize the first letter of each word in a string using JavaScript?
- Capitalizing first letter of each word JavaScript
- How to print the first character of each word in a String in Java?
- Return String by capitalizing first letter of each word and rest in lower case with JavaScript?
- Capitalize last letter and Lowercase first letter of a word in Java
- How to get first letter of each word using regular expression in Java?
- Python program to capitalize each word's first letter
- Golang program to capitalize first character of each word in a string
- Java Program to Capitalize the first character of each word in a String
- Make first letter of a string uppercase in JavaScript?

Advertisements