c#中将整数转化为字符串
Given a character array and we have to convert it into a string.
给定一个字符数组,我们必须将其转换为字符串。
char []转换为C#中的字符串 (char[] to string in C#)
In C#, we can convert a character array to the string, for this – we can create a new string from the character array.
在C#中,我们可以将字符数组转换为string ,为此–我们可以从字符数组创建一个新的字符串。
Syntax:
句法:
string string_object = new string(character_array);
It accepts a character array as an arguments and creates new string.
它接受一个字符数组作为参数并创建新的字符串。
Example:
例:
Input:
char[] char_arr = { 'H', 'e', 'l', 'l', 'o'};
Creating string:
string str = new string(char_arr);
Output:
str = "Hello"
Code:
码:
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
char[] char_arr = { 'H', 'e', 'l', 'l', 'o'};
//converting char[] to string
string str = new string(char_arr);
//printing string
Console.WriteLine("str = " + str);
//hit ENTER to exit
Console.ReadLine();
}
}
}
Output
输出量
str = Hello
翻译自: https://www.includehelp.com/dot-net/convert-char-array-to-string-in-c-sharp.aspx
c#中将整数转化为字符串