Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:05:16+00:00 2026-06-13T19:05:16+00:00

Hi I am trying to split a string into an array of chars but

  • 0

Hi I am trying to split a string into an array of chars but for some reason the result is not what I expect.I passed this piece of code threw with the debugger and i gave it the string “34325”.When I reach the part of the code that converts the string into an array of chars for some reason I can see two sets of chars in the debugger.I get something like this:

char[0] = 51 ‘3’
char[1] = 52 ‘4’
char[2] = 51 ‘3’
char[3] = 50 ‘2’
char[4] = 53 ‘5’

When I then convert each element of the char array into an int the first number of is always take : 51 , 52 ,51 , 50 , 53.

My question is how can I correct this so I get 3 , 4 , 3 , 2 , 5?
And also from where are this numbers coming from when I use the toCharArray() method : 51 ,52 ,51 ,50 53?

This is my code:

    value = TextBox1.Text;

    char[] numberChars = value.ToCharArray();
    int[] numbers = numberChars.Select(x => Convert.ToInt32(x)).ToArray();

    for( int i = 0; i < numbers.Length; i++ ) {
        TextBox2.Text += numbers[i] + " ";
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:05:17+00:00Added an answer on June 13, 2026 at 7:05 pm

    If I understand your question correctly, you would like to split the string into integer numbers representing the digits, as follows: "34325" becomes new int[] {3,4,3,2,5}.

    Change your code as follows to interpret each character that represents a digit as a single-digit number:

     int[] numbers = numberChars.Select(x => ((int)x)-'0').ToArray();
    

    Here is a link to a demo on ideone.

    The reason you see numbers 51, 52, and so on is that you see ASCII codes for the corresponding digits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I am trying to split a string into an array. This is the code
I'm trying to split a utf8 encoded string into an array of chars. The
I'm trying to split a string into an array. I've tried str_split() but the
I'm trying to split a string into a int list for further processing. But
I'm trying to find a way to split a String into an array of
I am trying to split a string into an array of word pairs in
I'm trying to split all the words in a string into an array in
Im trying to split a String into an Array. In PHP I normally use
i'm trying to use php to split a string into array components using either

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.