how i split a string if it has two differnt symbol as "," &"-"
i have a string as
my_string="java-3,os-2,internet-4,c-1,ospm-2"
i want that each subject name and digit comes into different array
how it, i can do
Status:
Open Mar 01, 2008 - 01:47 AM
asp.net 2
3answers
Answers
Mar 26, 2009 - 03:24 AM
You can not access a function from usercontorl class unless you have instance of it in your page and the function is public. e.g. (usercontorl1.function1())
otherwise, you should have that function in a class inside AppCode
Mar 26, 2009 - 02:41 PM
Sorry, for this mistake post
Anyway, no direct way to do this. However, there is two methods coming to my mind to this. first one be use "," and "-" as seperator which will split them to one array {java, 3, os, 2...}.
string[] array = input.Split(",-".ToCharArray());
The back draw of this method is the consistency if the input is inconsistence (e.g. java-3,os,internet-4,5-6-1,ospm-2).
Second method is the following
string[] array2 = input.Split(',');
List set1 = new List();
List set2 = new List();
for (int i = 0; i < array2.Length; i++)
{
string[] temp = array2[i].Split('-');
if (temp.Length == 2)
{
set1.Add(temp[0]);
set2.Add(temp[1]);
}
}
Apr 17, 2009 - 03:32 PM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment