c#中将整数转化为字符串_在C#中将char数组转换为字符串

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#中将整数转化为字符串

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值