Need help with first C# console program

Discussion in 'C Programming' started by codingnoob3593, Sep 4, 2015.

  1. codingnoob3593

    codingnoob3593

    Joined:
    Sep 4, 2015
    Messages:
    1
    Likes Received:
    0
    Hey guys, I am making a very simple c# console application to turn letters into numbers (a = 1, b = 2, c = 3) and so on. I have managed to make it work for single letters, but now I want to make it work for words (for example, I could just type "abc" and get the output "1, 2, 3"). I am having problems making it work, so I was hoping somebody could tell me how I need to edit my code to make it work. Thanks!

    using System;

    namespace FirstProgram
    {
    class MainClass
    {
    static public void Main ()
    {
    string[] letters = new string[25];

    letters [0] = "a";
    letters [1] = "b";
    letters [2] = "c";
    letters [3] = "d";
    letters [4] = "e";
    letters [5] = "f";
    letters [6] = "g";
    letters [7] = "h";
    letters [8] = "i";
    letters [9] = "j";
    letters [10] = "k";
    letters [11] = "l";
    letters [12] = "m";
    letters [13] = "n";
    letters [14] = "o";
    letters [15] = "p";
    letters [16] = "q";
    letters [17] = "r";
    letters [18] = "s";
    letters [19] = "t";
    letters [20] = "u";
    letters [21] = "v";
    letters [22] = "w";
    letters [23] = "x";
    letters [24] = "y";

    int[] numbers = new int[25];

    numbers [0] = 1;
    numbers [1] = 2;
    numbers [2] = 3;
    numbers [3] = 4;
    numbers [4] = 5;
    numbers [5] = 6;
    numbers [6] = 7;
    numbers [7] = 8;
    numbers [8] = 9;
    numbers [9] = 10;
    numbers [10] = 11;
    numbers [11] = 12;
    numbers [12] = 13;
    numbers [13] = 14;
    numbers [14] = 15;
    numbers [15] = 16;
    numbers [16] = 17;
    numbers [17] = 18;
    numbers [18] = 19;
    numbers [19] = 20;
    numbers [20] = 21;
    numbers [21] = 22;
    numbers [22] = 23;
    numbers [23] = 24;
    numbers [24] = 25;

    Console.WriteLine ("Write a letter.");
    string input = Console.ReadLine ();

    for (int i = 0; i <= 24; i++)
    {
    if (input == letters )
    {
    Console.WriteLine (numbers );
    }
    }
    Console.ReadKey ();
    }
    }
    }
     
    codingnoob3593, Sep 4, 2015
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    1,244
    Egor Bolonev
    Jun 30, 2003
  2. Miktor
    Replies:
    7
    Views:
    12,801
    Joe Bacigalupa
    Aug 9, 2005
  3. McCann, Brian
    Replies:
    1
    Views:
    386
    Bjoern Schliessmann
    Oct 20, 2007
  4. jan.rebada@gmail.com

    Reading console output and writing to console

    jan.rebada@gmail.com, Jan 26, 2008, in forum: C++
    Replies:
    5
    Views:
    3,779
    James Kanze
    Mar 4, 2008
  5. pythonbrian
    Replies:
    1
    Views:
    551
    Steve Holden
    Feb 7, 2008
  6. WP
    Replies:
    1
    Views:
    329
  7. Kris Rudin

    console app w/o seeing console?

    Kris Rudin, Nov 11, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    321
    Randy Charles Morin
    Nov 11, 2003
  8. Christopher M. Lusardi
    Replies:
    3
    Views:
    402
    Alan J. Flavell
    Oct 19, 2003
Loading...