Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 convert an array of characters into a string in C#?
Let us first set an array of 5 characters −
char[] ch = new char[15]; ch[0] = 'T'; ch[1] = 'r'; ch[2] = 'i'; ch[3] = 'c'; ch[4] = 'k';
Now convert them into a string −
string str = new string(ch);
Here is the complete code −
Example
Using System;
class Program {
static void Main() {
char[] ch = new char[15];
ch[0] = 'T';
ch[1] = 'r';
ch[2] = 'i';
ch[3] = 'c';
ch[4] = 'k';
// converting to string
string str = new string(ch);
Console.WriteLine(str);
}
}Advertisements