- Joined
- Sep 4, 2015
- Messages
- 1
- Reaction score
- 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 ();
}
}
}
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 ();
}
}
}