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

  • SEARCH
  • Home
  • 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 7529305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:37:36+00:00 2026-05-30T04:37:36+00:00

I am trying to input a string into a C# console app, have it

  • 0

I am trying to input a string into a C# console app, have it break the string into an array of its characters, and then have it iterate through the array of characters and assign each character an integer corresponding to its alphabetic position(1-26, a-z) and populate a new array with the integers.

The input block up to the array of characters I already have:

string plainText;
Console.Write ("String:");
plainText = Console.ReadLine();
char[] plainTextArray = plainText.ToCharArray();

Not looking for a completed solution, more of a suggested direction to look in for a function(s) to implement.

Thanks.

  • 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-05-30T04:37:37+00:00Added an answer on May 30, 2026 at 4:37 am

    Two possible solutions here:

    • Convert the char to an int, subtract an appropriate amount to put it between 1-52, and take the number mod 26 (or .ToUpper() or ToLower() the string beforehand and put it in the 1-26 range)
    • Create and prepopulate a mapping (something like Dictionary<char, int> that takes a char and returns the appropriate number

    I recommend the first option.

    EDIT:
    Based on phoog’s comment, I recommend the following method:

    1. Use String.ToUpper() to convert the string to uppercase.
    2. Use String.ToCharArray() to create the array of uppercase characters.
    3. Create an int[] array that is the same size as the char[] array.
    4. Iterate through the length of the arrays, converting char to int using `(plainTextArray[i] – ‘a’) + 1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a Delphi function that will split an input string into
I am trying to split a string into an array of word pairs in
I've been trying different methods for converting a user string input into an int
I am trying to use JTidy (jtidy-r938.jar) to sanitize an input HTML string, but
I'm trying to sanitize a string that involves user input without having to resort
I'm trying to debug my iPhone app (a basic counter) and I have a
I'm trying to parse a int from a String array element. Here is my
I have been running into OutOfMemory Exceptions while trying to load an 800MB text
I'm trying to insert a date (This is a string) into a postgres database
I have the following Java socket client app, that sends same string to socket

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.