How would I convert this string to an Array?
"243, 567, 324, 345"
Where each number becomes a new element in that Array.
Thanks 3 1433
I'm not sure if you want a string array or an integer array but this should
help:
using System.Text.Reg ularExpressions ;
....
Regex rx = new Regex(", ");
string[] myarray = rx.Split("243, 567, 324, 345"); // creates a string array
containing each number
foreach (string s in myarray)
{
// show the string version of this array item
MessageBox.Show ("'" + s + "'");
// Convert it to an integer if you like
int myinteger = Int32.Parse(s);
// add the integer to an array here if you like...
}
ShaneB
"Tome73" <To****@discuss ions.microsoft. com> wrote in message
news:2D******** *************** ***********@mic rosoft.com... How would I convert this string to an Array? "243, 567, 324, 345" Where each number becomes a new element in that Array. Thanks
For a simple split like this one, you can easily use the Split function
of the String class. Check your online help for examples.
hth, Philipp
Tome73 wrote: How would I convert this string to an Array? "243, 567, 324, 345" Where each number becomes a new element in that Array. Thanks
The reason I didn't mention string.split is because it won't work as
expected in his case. In the original poster's question, the string he
provided contained a space after each comma. That means the code would have
to look like this:
string s = "243, 567, 324, 345";
string[] myarray = s.Split(new char[]{',' , " "});
As a result, myarray will contains 8 items...because string.split split the
array on each occurance of each character.
Regex.Split() will split it properly and accepts a string input as well.
ShaneB
"Philipp Sumi" <sp*******@this domaindoesntexi st.org> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. For a simple split like this one, you can easily use the Split function of the String class. Check your online help for examples.
hth, Philipp Tome73 wrote:
How would I convert this string to an Array? "243, 567, 324, 345" Where each number becomes a new element in that Array. Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
At work we have an excel file that contains the list of medications and
their corresponding strengths. I would like to save the excel file as a
text list and paste this list into a javascript function and have JS put
this into an array. Then JS would use this array to create a selection
list which displays only the names of the drugs. When the user
selections one of the drugs, another selection list will be loaded with
the avaiable...
|
by: Tamir Khason |
last post by:
How can I convert (elegant way) Collection to Array without looping and new
instances.
E.G:
I want to add elements of one menu to other, so
secondMenu.MenuItems.AddRange(firstMenu.MenuItems); //Error here: Argument
'1': cannot convert from 'System.Windows.Forms.Menu.MenuItemCollection' to
'System.Windows.Forms.MenuItem'
So please advice.
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that the data converted from the byte array into a string
, is not what i expect.
example:
- the data returned from the socket is (byte array)
"Usuario Sin Atribuciones Para Esta Función"
|
by: MuZZy |
last post by:
Hi,
I just wonder if someone can help me wit this -
i have a byte array and need to convert it to short array, creating
short numbers by combining bytes by pairs:
My array: byte, byte, byte, etc.
I need: short = byte+byte, short = byte+byte, etc.
|
by: Peter Nofelt |
last post by:
Hi all,
My scenario is as follows:
* Receive a base 1 array (index starts at 1 instead of 0) of data from
a COM component .
* Need to pass this array to a .net component that requires its array
index to start at 0.
* As a result, must convert array from base1 to base 0.
| |
by: Koolrans |
last post by:
Hi All,
Don't know if this is covered somewhere else. Could not find it. I
have a problem for which I need a solution.
I have an array of char chr. I want to convert this to an array
of uint32 it. What I require is that for the first integer, the
value would be of the four chars. This means, the first 8 bits will be
tmp, the second 8 bits would be tmp and so on.
|
by: =?Utf-8?B?YW1pcg==?= |
last post by:
I am trying to convert a Dictionary into an array so that I can compare
values and compare keys individually.
I am looking for a solution like array i.e array of array.
|
by: est |
last post by:
From python manual
str( )
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
with repr(object) is that str(object) does not always attempt to
return a string that is acceptable to eval(); its goal is to return a
printable string. If no argument is given, returns the empty string,
''.
|
by: myotheraccount |
last post by:
Hello,
Is there a way to convert a DataRow to a StringArray, without looping
through all of the items of the DataRow?
Basically, I'm trying to get the results of a query and put them into
a listbox.
Right now it is done like this:
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |