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 17 1566
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
Hi,
What are those VB conversion functions strong.
Dim charar As Char() = {"1"c, "2"c, "3"c}
Dim B As String = CStr(charar)
Cor
"eBob.com" <fa******@totallybogus.comschreef in bericht
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
Geez, I did look at all String methods but never thought to look at the
constructor! That's the solution I like best, but thanks to ALL responders.
You guys are great.
Thanks, Bob
"Stephany Young" <noone@localhostwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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
"eBob.com" <fa******@totallybogus.comschrieb:
>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.
There's nothing easier than that:
\\\
Dim c() As Char = {"A"c, "B"c, "C"c}
Dim s As String = c
MsgBox(s)
///
VB provides an implicit widening conversion for 'Char()' -'String', even
with 'Option Strict On'. Widening conversions never fail because the value
domain of the target type is a superset of the value domain of the source
type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"eBob.com" <fa******@totallybogus.comschrieb:
>>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.
There's nothing easier than that:
\\\
Dim c() As Char = {"A"c, "B"c, "C"c}
Dim s As String = c
MsgBox(s)
///
VB provides an implicit widening conversion for 'Char()' -'String', even
with 'Option Strict On'. Widening conversions never fail because the
value domain of the target type is a superset of the value domain of the
source type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thanks Herfried. That's interesting and useful. I need only so many
characters starting at a specific offset within the char array. As someone
else pointed out a String constructor overload can do exactly that. But I
like the capability you've made me aware of and I know I'll be using it
soon.
Thanks again, Bob
Herfried K. Wagner [MVP] wrote:
"eBob.com" <fa******@totallybogus.comschrieb:
>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.
There's nothing easier than that:
\\\
Dim c() As Char = {"A"c, "B"c, "C"c}
Dim s As String = c
MsgBox(s)
///
VB provides an implicit widening conversion for 'Char()' -'String',
even with 'Option Strict On'. Widening conversions never fail because
the value domain of the target type is a superset of the value domain of
the source type.
As it's an implicit conversion, you can make it explicit if you want
without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
:)
--
Göran Andersson
_____ http://www.guffa.com
Goran,
Yours is a C# aproach, which has a lack of the strong Conversion methods
from VB. have a look at my answer.
Although I find the one from Herfried very much better.
Cor
"Göran Andersson" <gu***@guffa.comschreef in bericht
news:em**************@TK2MSFTNGP04.phx.gbl...
Herfried K. Wagner [MVP] wrote:
>"eBob.com" <fa******@totallybogus.comschrieb:
>>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.
There's nothing easier than that:
\\\ Dim c() As Char = {"A"c, "B"c, "C"c} Dim s As String = c MsgBox(s) ///
VB provides an implicit widening conversion for 'Char()' -'String', even with 'Option Strict On'. Widening conversions never fail because the value domain of the target type is a superset of the value domain of the source type.
As it's an implicit conversion, you can make it explicit if you want
without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
:)
--
Göran Andersson
_____ http://www.guffa.com
Cor Ligthert[MVP] wrote:
Goran,
Yours is a C# aproach, which has a lack of the strong Conversion methods
from VB. have a look at my answer.
Although I find the one from Herfried very much better.
Cor
Not at all. It's the .NET approach. It's not specific to any language,
which is proven by the fact that it works just a well in VB.
The .NET approach doesn't lack anything in this case, as the VB approach
doesn't add anything. It just works as a wrapper.
--
Göran Andersson
_____ http://www.guffa.com
Goran,
Do you want to say that VB is not .Net while C# is?
I assume that in your idea the System.Net namespaces means .Net.
(But it is not)
Cor
"Göran Andersson" <gu***@guffa.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
Cor Ligthert[MVP] wrote:
>Goran,
Yours is a C# aproach, which has a lack of the strong Conversion methods from VB. have a look at my answer.
Although I find the one from Herfried very much better.
Cor
Not at all. It's the .NET approach. It's not specific to any language,
which is proven by the fact that it works just a well in VB.
The .NET approach doesn't lack anything in this case, as the VB approach
doesn't add anything. It just works as a wrapper.
--
Göran Andersson
_____ http://www.guffa.com
"Göran Andersson" <gu***@guffa.comschrieb:
>>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.
There's nothing easier than that:
\\\ Dim c() As Char = {"A"c, "B"c, "C"c} Dim s As String = c MsgBox(s) ///
VB provides an implicit widening conversion for 'Char()' -'String', even with 'Option Strict On'. Widening conversions never fail because the value domain of the target type is a superset of the value domain of the source type.
As it's an implicit conversion, you can make it explicit if you want
without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
Well, I do not see any reason for that as widening conversions are not
harmful and always succeed. There's nothing wrong with implicit widening
conversions. I would not write 'Dim n As Long = CLng(<Integer>)' too.
Widening conversions are similar to the type/subtype relationship and I
assume you would not write 'Dim x As BaseClass = DirectCast(<DerivedClass>,
BaseClass)' in your code.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Cor Ligthert[MVP] wrote:
Do you want to say that VB is not .Net while C# is?
No, you are just trying to read it that way.
--
Göran Andersson
_____ http://www.guffa.com
Herfried K. Wagner [MVP] wrote:
>As it's an implicit conversion, you can make it explicit if you want without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
Well, I do not see any reason for that as widening conversions are not
harmful and always succeed. There's nothing wrong with implicit
widening conversions. I would not write 'Dim n As Long =
CLng(<Integer>)' too. Widening conversions are similar to the
type/subtype relationship and I assume you would not write 'Dim x As
BaseClass = DirectCast(<DerivedClass>, BaseClass)' in your code.
The difference is that the conversion is creating a new object.
--
Göran Andersson
_____ http://www.guffa.com
"Göran Andersson" <gu***@guffa.comschrieb:
>>As it's an implicit conversion, you can make it explicit if you want without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
Well, I do not see any reason for that as widening conversions are not harmful and always succeed. There's nothing wrong with implicit widening conversions. I would not write 'Dim n As Long = CLng(<Integer>)' too. Widening conversions are similar to the type/subtype relationship and I assume you would not write 'Dim x As BaseClass = DirectCast(<DerivedClass>, BaseClass)' in your code.
The difference is that the conversion is creating a new object.
Well, I know that, but I do not see any reason for using an explicit
conversion because VB provides implicit widening conversions (which cannot
even be turned off!).
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Herfried K. Wagner [MVP] wrote:
"Göran Andersson" <gu***@guffa.comschrieb:
>>>As it's an implicit conversion, you can make it explicit if you want without changing the resulting code:
Dim s As String = New String(c)
More to type, but it more clearly shows what's actally going on.
Well, I do not see any reason for that as widening conversions are not harmful and always succeed. There's nothing wrong with implicit widening conversions. I would not write 'Dim n As Long = CLng(<Integer>)' too. Widening conversions are similar to the type/subtype relationship and I assume you would not write 'Dim x As BaseClass = DirectCast(<DerivedClass>, BaseClass)' in your code.
The difference is that the conversion is creating a new object.
Well, I know that, but I do not see any reason for using an explicit
conversion because VB provides implicit widening conversions (which
cannot even be turned off!).
For readability. The code more closely resembles what's actually
happening, and perhaps also more closely resembles the intention of the
programmer.
I often use explicit conversions even if there might be an implicit
conversion. It's easier to maintain the code when it says exactly what's
happening.
--
Göran Andersson
_____ http://www.guffa.com
Goran,
I often use explicit conversions even if there might be an implicit
conversion. It's easier to maintain the code when it says exactly what's
happening.
I knew bookkeepers who where checking every calculation done by a computer
by hand.
I don't know why your statement did remind me of this.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where...
|
by: Juan |
last post by:
Does any one know if there are reported bugs when concatenating strings?
When debugging each variable has the correct value but when I try to
concatenate them some values are missing (I can´t see...
|
by: Peter |
last post by:
Hi,
I want to use an array str, while each array element str
is an array of chars of fixed length, say 40;
The best way to handle this in C# is StringBuilder I guess,
but as legacy C++ code...
|
by: Richard L Rosenheim |
last post by:
Is there any built-in method or mechanism for concatenating two arrays of
byte together?
I haven't come across anything to do this, and was just checking before I
implement some code.
Richard...
|
by: c |
last post by:
Hi everybody.
I'm working on converting a program wriiten on perl to C, and facing a
problem with concatenate strings.
Now here is a small program that descripe the problem, if you help me
to...
|
by: Paulers |
last post by:
Hello,
I have a string that I am trying to add each char to a datatable row.
for example if I have a string that looks like "abcdefg", I would like
to break it up into an array of characters...
|
by: clinisbut |
last post by:
I'm not sure if this is the right group, but I didn't found any other
more appropiate to post my problem.
I'm trying to concatenate chars using the Glib library and I'm getting
strange...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |