How to convert string to arrylist in c# [Resolved]

Posted by Allemahesh under C# on 7/18/2013 | Points: 10 | Views : 2424 | Status : [Member] [MVP] | Replies : 6
I have a string.
string str = "dotnetfunda";

Now I want to convert this to array list.
Can any one help me.




Responses

Posted by: Ssj_Kumar on: 7/18/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
string str = "dotnetfunda";
ArrayList arr = new ArrayList(str.ToArray());

Regards,
Jayakumar Selvakani

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Phagu007 on: 7/19/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
You need to try this given code for convert string to array list in C Sharp
ArrayList array1 = new ArrayList(str.ToArray());


Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/18/2013 [Member] Starter | Points: 25

Up
0
Down
string str = "dotnetfunda";
ArrayList arr = new ArrayList();
arr.Add(str);

Regards,
Jayakumar Selvakani

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/18/2013 [Member] Starter | Points: 25

Up
0
Down
Hi
 string[] mystringArray=new string[2];

mystringArray[0]="A";
mystringArray[1]="b";
Arraylist ar=new Arraylist();
ar.addrange(mystringArray);


Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 7/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear developers,
I have used the above code like this.

string str = "dotnetfunda";
ArrayList arr = new ArrayList();
arr.Add(str);
string str1 = Convert.ToString(arr[0])
But my str1 is returning "dotnetfunda", but it should be d.

Can any one help me.

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 7/19/2013 [Member] Starter | Points: 25

Up
0
Down
To Convert String in Char Array:

string s = "dotnetfunda";

string[] a = s.Select(c => c.ToString()).ToArray();


If you're using an older version of C#:

string s = "dotnetfunda";

string[] a = new string[s.Length];
for(int i = 0; i < s.Length; i++) {
a[i] = s[i].ToString();
}


http://hashtagakash.wordpress.com/

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response