连接数组中的字符 [英] Concatenating Chars in an Array

查看:85
本文介绍了连接数组中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道写起来并不难,但我一直无法找到一个方法

,它将获取一个字符数组的元素并将它们连接成一个

字符串。我已经看过String成员和Char成员,并且没有找到任何这样的方法。但它似乎很明显。所以我认为我只是没有确定正确的谷歌搜索论点。


我只想要一个连接一些连续元素的函数

Char数组。我知道它必须存在,我才能找到它。


谢谢,鲍勃

解决方案

在文章< Ov ************** @ TK2MSFTNGP04.phx.gbl>,eBob.com

< fa ***** *@totallybogus.com写道:


我知道写起来并不难,但我一直找不到方法

将获取字符数组的元素并将它们连接成一个

字符串。我已经看过String成员和Char成员,并且没有找到任何这样的方法。但它似乎很明显。所以我认为我只是没有确定正确的谷歌搜索论点。


我只想要一个连接一些连续元素的函数

Char数组。我知道它必须存在,我才能找到它。



Encoding.ASCII.GetString

-

JB Moreno


Dim _string = New String(_charrarray,_x,_ y)

其中:


_chararray是你的Char数组

_x是第一个元素的索引

_y是元素的数量

" eBob.com" < fa ****** @ totallybogus.com写信息

新闻:Ov ************** @ TK2MSFTNGP04.phx.gbl ...


>我知道写起来并不难,但我一直无法找到一个将采用字符数组元素的
方法并将它们连接成一个字符串。我看过String成员和Char成员,并且没有找到任何这样的方法。但它似乎很明显。所以我认为我没有找到正确的谷歌搜索论点。


我只想要一个能连接一些连续元素的功能

a Char数组。我知道它必须存在,我才能找到它。


谢谢,鲍勃


< blockquote> 8月29日上午6:56,eBob.com < faken ... @ totallybogus.comwrote:


我知道写起来并不难,但我一直无法找到方法

将获取一个字符数组的元素并将它们连接成一个

字符串。我已经看过String成员和Char成员,并且没有找到任何这样的方法。但它似乎很明显。所以我认为我只是没有确定正确的谷歌搜索论点。


我只想要一个连接一些连续元素的函数

Char数组。我知道它必须存在,我才能找到它。


谢谢,Bob



String type有一个构造函数,可以将一个char数组作为参数,我希望这样做:


''定义你的char数组

Dim charArr()作为Char = _

{" b"," a"," s"," i"," c"}

Dim str As New String(charArr)

''这是你的连接字符串

MsgBox(str)

HTH,


OnurGüzel


I know it wouldn''t be hard to write, but I have been unable to find a method
which will take elements of a character array and concatenate them into a
string. I''ve looked at both String members and Char members and haven''t
found any such method. But it seems so obvious. So I figure I just haven''t
hit upon the right Google search arguments.

I just want a function which will concatenate some consecutive elements of a
Char array. I know it must exist, I just haven''t been able to find it.

Thanks, Bob

解决方案

In article <Ov**************@TK2MSFTNGP04.phx.gbl>, eBob.com
<fa******@totallybogus.comwrote:

I know it wouldn''t be hard to write, but I have been unable to find a method
which will take elements of a character array and concatenate them into a
string. I''ve looked at both String members and Char members and haven''t
found any such method. But it seems so obvious. So I figure I just haven''t
hit upon the right Google search arguments.

I just want a function which will concatenate some consecutive elements of a
Char array. I know it must exist, I just haven''t been able to find it.

Encoding.ASCII.GetString

--
J.B. Moreno


Dim _string = New String(_charrarray, _x, _y)

where:

_chararray is your Array of Char
_x is the index of the first element
_y is the number of elements
"eBob.com" <fa******@totallybogus.comwrote in message
news:Ov**************@TK2MSFTNGP04.phx.gbl...

>I know it wouldn''t be hard to write, but I have been unable to find a
method which will take elements of a character array and concatenate them
into a string. I''ve looked at both String members and Char members and
haven''t found any such method. But it seems so obvious. So I figure I
just haven''t hit upon the right Google search arguments.

I just want a function which will concatenate some consecutive elements of
a Char array. I know it must exist, I just haven''t been able to find it.

Thanks, Bob


On Aug 29, 6:56 am, "eBob.com" <faken...@totallybogus.comwrote:

I know it wouldn''t be hard to write, but I have been unable to find a method
which will take elements of a character array and concatenate them into a
string. I''ve looked at both String members and Char members and haven''t
found any such method. But it seems so obvious. So I figure I just haven''t
hit upon the right Google search arguments.

I just want a function which will concatenate some consecutive elements of a
Char array. I know it must exist, I just haven''t been able to find it.

Thanks, Bob

String type has constructor that may taka a char array as argument, i
hope that does:

'' Define your char array
Dim charArr() As Char = _
{"b", "a", "s", "i", "c"}
Dim str As New String(charArr)
'' Here is your concatenated string
MsgBox(str)
HTH,

Onur Güzel


这篇关于连接数组中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆