Click here to Skip to main content
12,746,296 members (31,974 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hi frens,


I have a string of arrays
ex :string[] abc= new string[] { "3", "2", "1" };

how can i get the value 3 using foreach




if i use

foreach(int x in abc )
{

}

x is returning 51 which is ascii equivalent of 3 but i need 3 ..
please help me...


thanks in advance
darshan
Posted 27-Dec-12 2:08am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

string[] abc = new string[] { "3", "2", "1" };
            foreach (string s in abc)
            {
                //Your code here
            }

Instead of int in foreach use string. I have tried above code, its working fine.
  Permalink  
Comments
darshan559 27-Dec-12 7:52am
   
thank u so much..it worked
Vani Kulkarni 27-Dec-12 7:58am
   
Great! :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I have a string of arrays
string[] abc= new string[] { "3", "2", "1" };

foreach(string x in abc )
{
Console.WriteLins(x);
}
  Permalink  
v2
Comments
darshan559 27-Dec-12 7:52am
   
thank u so much..it worked
Oleksandr Kulchytskyi 27-Dec-12 7:55am
   
So if you mind,please rate our answer ;)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

hi,

Use this :-
string[] abc = new string[] { "3", "2", "1" };

            foreach (string x in abc)
            {
                Console.Write(Convert.ToInt32(x));
            }
  Permalink  
Comments
darshan559 27-Dec-12 7:52am
   
thank u so much..it worked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100