
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to calculate the length of the string using C#?
Use the String.Length property in C# to get the length of the string.
str.Length
The property calculates the words in the string and displays the length of the specified string, for example, the string Amit has 4 characters −
string str = "Amit";
Example
The following is the C# program to calculate the string length −
using System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { string str = "Amit"; Console.WriteLine("String: "+str); Console.WriteLine("String Length: "+str.Length); Console.ReadKey(); } } }
Output
String: Amit String Length: 4
- Related Questions & Answers
- Python Program to Calculate the Length of a String Without Using a Library Function
- How to calculate the Size of Folder using C#?
- C++ Program to Find the Length of a String
- C program to find the length of a string?
- How to find the length of the longest substring from the given string without repeating the characters using C#?
- Write a C program to calculate the average word length of a sentence using while loop
- How to calculate the power exponent value using C#?
- How MySQL LENGTH() function measures the string length?
- How to calculate the size of folder using Java?
- How to calculate the volume of a sphere using C programming language?
- How to get the length of a string in Python?
- How to get the length of a string in JavaScript?
- How to get the Length of a String in Java?
- How to calculate power of three using C#?
- How to find the length of the StringBuilder in C#?
Advertisements