473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

split a string and store their value in an array

Good evening everyone
I am sunita. Currently i am developing a project in asp.net and i am facing a problem in splitting a string.can any one help me....
I am using C#
Jan 30 '08 #1
2 1960
kunal pawar
297 100+
try this

// string seperated by semi-colons ';'
string info = "mark;smith;123 csharp drive;toronto;canada";

string[] arInfo = new string[4];

// define which character is seperating fields
char[] splitter = {';'};

arInfo = info.Split(splitter);
Jan 30 '08 #2
Plater
7,872 Expert 4TB
try this

// string seperated by semi-colons ';'
string info = "mark;smith;123 csharp drive;toronto;canada";

string[] arInfo = new string[4];

// define which character is seperating fields
char[] splitter = {';'};

arInfo = info.Split(splitter);
That is a good example, but this:
Expand|Select|Wrap|Line Numbers
  1. string[] arInfo = new string[4];
  2.  
is not entireley needed. There is no need to specify a size for the split() operation as it will create a new array for you anyway.

Using a zero size is like declaring it null, useful for testing sometimes.
Expand|Select|Wrap|Line Numbers
  1. string[] arInfo = new string[0];
  2.  
Jan 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: andrewcw | last post by:
The split function takes as a parameter what I understand as array of Char. I can define the delimiter like this: string innerText = new string; char chSplit={'='};...
1
by: Craig G | last post by:
i have the little jscript which i use for returning a value from a popupModal. but i want to extend this so that i cant split the string into different values in future the string will return a...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
5
by: kurt sune | last post by:
The code: Dim aLine As String = "cat" & vbNewLine & "dog" & vbNewLine & "fox" & vbNewLine Dim csvColumns1 As String() = aLine.Split(vbNewLine, vbCr, vbLf) Dim csvColumns2 As String() =...
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
2
by: Digital Fart | last post by:
following code would split a string "a != b" into 2 strings "a" and "b". but is there a way to know what seperator was used? string charSeparators = { "=", ">=", "<=" , "!=" }; string s1 =...
3
by: edoardo.poeta | last post by:
I'm a dummy. I have a basic knowledge of javascript and I want to split a string, but I receive an error at line 15. Where my error in make the array? Why? Can someone help me to resolve? Thank's....
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
5
by: chindanoor | last post by:
As i used split method in my local Machine(jdk1.4) it was working fine.., When i try to use in the server(which is jdk1.3 version) unable to support it.., As i m able to do it with StringTokenizer...
4
by: dschu012 | last post by:
Ignore the title it isn't exactly what I meant, and after reading it the title sounds kinda stupid. I have an list of numbers as an ascii string that I need to split by a token and store the...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.