C
C#•2mo ago
Scrolly

ALPHABETIC TELEPHONE NUMBER TRANSLATOR for Class

I have been trying to figure this out for a few days now. Here is the full question: "Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion: A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J, K, and L = 5 M, N, and O = 6 P, Q, R, and S = 7 T, U, and V = 8 W, X, Y, and Z = 9 Create an application that lets the user enter a 10-character telephone number in the format XXX-XXX-XXXX . The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555- GET-FOOD, the application should display 555-438-3663." I am very new to c# and understand basic code. I am able to code it to where it accepts the inputted Alphabetic phone number converted it to a char array. I am sure I have to use some type of foreach loop or something like that. I have a good idea on what I am supposed to do, but I cannot put it into code. I have tried looking up the question and found a few solutions, but I do not understand all of it (which is important to me). Also, I will be launching it with the click of a button private void button1_Click(object sender, EventArgs e)
84 Replies
Mayor McCheese
Mayor McCheese•2mo ago
What have you tried so far? $code
MODiX
MODiX•2mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Scrolly
Scrolly•2mo ago
public enum AlphaNumber
{
A=2, B=2, C=2, D=3, E=3, F=3, G=4, H=4, I=4, J=5, K=5, L=5,
M=6, N=6, O=6, P=7, Q=7, R=7, S=8, T=8, U=8, V=9, W=9, X=9, Y=9, Z=9
}

public static class PhoneNumber
{
public static char ParseInput(char input)
{
if (input == '-' || char.IsDigit(input))
{
return input;
}

if (char.IsLetter(input))
{
var num = (AlphaNumber)(Enum.Parse(typeof(AlphaNumber), (char.IsLower(input) ? char.ToUpperInvariant(input) : input).ToString()));
return ((int)num).ToString()[0];
}

return '\0';
}
}
public enum AlphaNumber
{
A=2, B=2, C=2, D=3, E=3, F=3, G=4, H=4, I=4, J=5, K=5, L=5,
M=6, N=6, O=6, P=7, Q=7, R=7, S=8, T=8, U=8, V=9, W=9, X=9, Y=9, Z=9
}

public static class PhoneNumber
{
public static char ParseInput(char input)
{
if (input == '-' || char.IsDigit(input))
{
return input;
}

if (char.IsLetter(input))
{
var num = (AlphaNumber)(Enum.Parse(typeof(AlphaNumber), (char.IsLower(input) ? char.ToUpperInvariant(input) : input).ToString()));
return ((int)num).ToString()[0];
}

return '\0';
}
}
So I tried a version of this but I have already deleted it and tried to start over I was looking online and that is what I found, but I cannot figure what all this means, how to make it work for a button etc. I have the Enum, I have the char array from the input of the user
namespace Chapter8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void AlphNumberBox_TextChanged(object sender, EventArgs e)
{

}

private void ConvNumberBox_TextChanged(object sender, EventArgs e)
{

}

public enum AlphaNumberEnum
{
a = 2, b = 2, c = 2, d = 3, e = 3, f = 3, g = 4, h = 4, i = 4, j = 5, k = 5, l = 5,
m = 6, n = 6, o = 6, p = 7, q = 7, r = 7, s = 7, t = 8, u = 8, v = 8, w = 9, x = 9, y = 9, z = 9

}
private void button1_Click(object sender, EventArgs e)
{
var AlphNumber = AlphNumberBox.Text;
var AlphNumbersArr = AlphNumber.ToCharArray();
char[] ConvNumbersArr;

foreach (var character in AlphNumbersArr)
{

}

}
}
}
namespace Chapter8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void AlphNumberBox_TextChanged(object sender, EventArgs e)
{

}

private void ConvNumberBox_TextChanged(object sender, EventArgs e)
{

}

public enum AlphaNumberEnum
{
a = 2, b = 2, c = 2, d = 3, e = 3, f = 3, g = 4, h = 4, i = 4, j = 5, k = 5, l = 5,
m = 6, n = 6, o = 6, p = 7, q = 7, r = 7, s = 7, t = 8, u = 8, v = 8, w = 9, x = 9, y = 9, z = 9

}
private void button1_Click(object sender, EventArgs e)
{
var AlphNumber = AlphNumberBox.Text;
var AlphNumbersArr = AlphNumber.ToCharArray();
char[] ConvNumbersArr;

foreach (var character in AlphNumbersArr)
{

}

}
}
}
My idea was using the foreach, it determines whether the var is a letter or number. If a number, it assigns it to the ConvNumbersArr. If a letter, it uses the enum to convert it to its enum counterpart, then it assigns it to ConvNumbersArr. Then print after its finished running through all of the AlphNumbersArr. Hope that makes sense.
ACiDCA7
ACiDCA7•2mo ago
your plan sounds right
Scrolly
Scrolly•2mo ago
My main issue is the meat of the code. I cannot put my plan into code haha
ACiDCA7
ACiDCA7•2mo ago
well you already have your loop startred, character contains the letter or number that gets currently "checked" now like you wrote check if its letter or digit or dash
Scrolly
Scrolly•2mo ago
I would do an if else right? How can I make that
foreach (var character in AlphNumbersArr)
{
if (character.isLetter)
}
foreach (var character in AlphNumbersArr)
{
if (character.isLetter)
}
or something like that?
ACiDCA7
ACiDCA7•2mo ago
yea you can work with that so if its a letter you wanted to call your convert method
Scrolly
Scrolly•2mo ago
Yes!
ACiDCA7
ACiDCA7•2mo ago
go on
Scrolly
Scrolly•2mo ago
character.isLetter gives an error, how would I correctly write that?
ACiDCA7
ACiDCA7•2mo ago
try Char.IsLetter(character)
Scrolly
Scrolly•2mo ago
Okay that passed. Now here is my other problem and I apologize. I need to create the convert method. Is it able to access a convert method that I have to make within the if statement?
ACiDCA7
ACiDCA7•2mo ago
yes, you made it your self easy in this regard since the class and method is static you can call the method by writing PhoneNumber.ParseInput(character)
Scrolly
Scrolly•2mo ago
are you referencing this?
ACiDCA7
ACiDCA7•2mo ago
yea
Scrolly
Scrolly•2mo ago
I got that method online and I have no idea how it works. there is a lot that goes into that to which I dont understand lol
ACiDCA7
ACiDCA7•2mo ago
so you want to rewrite that to something you understand?
Scrolly
Scrolly•2mo ago
Yes exactly
ACiDCA7
ACiDCA7•2mo ago
do you have an idea how to tackle this? im trying to not spoonfeed you since this homework and you should learn and not copypaste. but i bring you on the right track if you get stuck somewhere ;)
Scrolly
Scrolly•2mo ago
I do appreciate that, i would rather have it that way do you think enum would be okay here?
ACiDCA7
ACiDCA7•2mo ago
since you have already the groundwork set to start checking each individual character how would you formulate the steps needed to convert the letter into the right number
Scrolly
Scrolly•2mo ago
I would have it reference the enum somehow and find its counterpart in the enum
ACiDCA7
ACiDCA7•2mo ago
thats not what i mean, forget the enum for a moment.. in plain simple english words what needs to be done?
Scrolly
Scrolly•2mo ago
I probably know but I am completely overlooking it
ACiDCA7
ACiDCA7•2mo ago
to be honest you already wrote like 90% of it in initial post
Scrolly
Scrolly•2mo ago
Okay, are you saying the one with the PhoneNumber method? I just dont understand it:/ i apologize
ACiDCA7
ACiDCA7•2mo ago
ok i guess im too vague
Scrolly
Scrolly•2mo ago
No I am just a huge noob loo lol
ACiDCA7
ACiDCA7•2mo ago
soooo you are looping over every char right? so now you need to convert that char into a number if its 'A' or 'B' or 'C' that is a 2 if its 'D' or 'E' or 'F' that is a 3 .... if you spell it out like this you can already kind of see the program that has to be written ;)
Scrolly
Scrolly•2mo ago
Yes! I tried writing something like that, but I could not format it correctly I tried to use a switch
ACiDCA7
ACiDCA7•2mo ago
well stick to the basics first ;) show me how you have written it with ifs
Scrolly
Scrolly•2mo ago
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || 'B' || 'C')
}
}
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || 'B' || 'C')
}
}
something like this? I cannot format that correctly though. I know I am on the right track though
ACiDCA7
ACiDCA7•2mo ago
if (character == 'A' ||character == 'B' ||character == 'C')
if (character == 'A' ||character == 'B' ||character == 'C')
to explain why it hase to be written like this after every || starts a new condition that has to be met just writing 'B' is not a condition that can be evaluated
Scrolly
Scrolly•2mo ago
No description
Scrolly
Scrolly•2mo ago
would it be char instead?
ACiDCA7
ACiDCA7•2mo ago
you are missing == twice
Scrolly
Scrolly•2mo ago
AHHHHH thank you so much
ACiDCA7
ACiDCA7•2mo ago
so to continue
if (character == 'A' || character == 'B' || character == 'C')
{
//next steps when the charcter is a,b or c go here
}
if (character == 'A' || character == 'B' || character == 'C')
{
//next steps when the charcter is a,b or c go here
}
Scrolly
Scrolly•2mo ago
So the value would be assigned to ConvNumbersArr right?
ACiDCA7
ACiDCA7•2mo ago
yes
Scrolly
Scrolly•2mo ago
Should I use a char array or a regular array for ConvNumbers
ACiDCA7
ACiDCA7•2mo ago
waht is a regular array for you?
Scrolly
Scrolly•2mo ago
Just a single dimensional array integer array Sorry lol there isnt a regular array I mean an integer array Wait I dont even need one
ACiDCA7
ACiDCA7•2mo ago
ok we have 2 problems/misunderstandings here 1. you dont need an extra array to fill an array(good job figuering it out yourself) 2. since you are using an array you have to tell it how long that array should be and when adding to that array you have to specify where in that array you want to fill the content
Scrolly
Scrolly•2mo ago
char[] ConvNumbersArr = new char[10]; that works for the converted phone number yes? 10 digit long
ACiDCA7
ACiDCA7•2mo ago
this is part of a solution yes
Scrolly
Scrolly•2mo ago
But, you are saying I dont even need that array I can just reassign the values in that array? in AlphNumbers
ACiDCA7
ACiDCA7•2mo ago
yes you can do this but this isnt really what i wanted to point to lets say you want to say the 3rd field in a array, doesnt matter which, should be 'B', how do you do this? this is still missing in your code
Scrolly
Scrolly•2mo ago
ConvNumbersArr[2] = 'B';
ACiDCA7
ACiDCA7•2mo ago
yes but in your code where does the 2 come from?
Scrolly
Scrolly•2mo ago
The 2 is the third field correct?
ACiDCA7
ACiDCA7•2mo ago
yes
Scrolly
Scrolly•2mo ago
0 = first var AlphNumbersArr = AlphNumber.ToCharArray(0,9);
var AlphNumbersArr = AlphNumber.ToCharArray(0,9);
var AlphNumbersArr = AlphNumber.ToCharArray(0,9);
I declared 10 maximum fields for this right?
ACiDCA7
ACiDCA7•2mo ago
no you misunderstood me so when you convert the first letter or number it goes into ConvNumbersArr[0] the second goes into ConvNumbersArr[1] and so on.
Scrolly
Scrolly•2mo ago
Yes, I was thinking about that right now. How would I get the foreach to know to paste it in the next value of the array?
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[0] = '2';
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[0] = '2';
because If i do something like this, it will just paste it into the first one
ACiDCA7
ACiDCA7•2mo ago
you use a number that you increment every time you run through the loop
Scrolly
Scrolly•2mo ago
Where would I put that at?
ACiDCA7
ACiDCA7•2mo ago
wanna take a guess?
Scrolly
Scrolly•2mo ago
I would say in the if? the if following the foreach
ACiDCA7
ACiDCA7•2mo ago
what exactly do you want to put there?
Scrolly
Scrolly•2mo ago
I would have to put something like i++ Would I have to use a for ? I think i understand I just dont know how to code it
ACiDCA7
ACiDCA7•2mo ago
ok yea that is a possibility, not really clean but possible, but there is still the open question where you create the i
Scrolly
Scrolly•2mo ago
i would be the index of the array
ACiDCA7
ACiDCA7•2mo ago
a for loop would also work and here most likely be the most correct choice but you arent forced to use it
Scrolly
Scrolly•2mo ago
So i can use a for after a foreach?
ACiDCA7
ACiDCA7•2mo ago
try to write the code how you think it could work, we can fix whats wrong together then
Scrolly
Scrolly•2mo ago
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
for (int i = 0; i < AlphNumbersArr.Length; i++)
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
for (int i = 0; i < AlphNumbersArr.Length; i++)
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
Hows that look
ACiDCA7
ACiDCA7•2mo ago
when i wrote that you could use a for loop i meant instead of foreach remove the for again and then just write int i = 0; above foreach
Scrolly
Scrolly•2mo ago
oh haha sorry
ACiDCA7
ACiDCA7•2mo ago
and then at the end write i++; but still inside foreach
Scrolly
Scrolly•2mo ago
foreach (var character in AlphNumbersArr; i++)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
foreach (var character in AlphNumbersArr; i++)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
like this? int i = 0;
private void button1_Click(object sender, EventArgs e)
{
var AlphNumber = AlphNumberBox.Text;
var AlphNumbersArr = AlphNumber.ToCharArray(0,9);
char[] ConvNumbersArr = new char[10];

int i = 0;

foreach (var character in AlphNumbersArr; i++)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
private void button1_Click(object sender, EventArgs e)
{
var AlphNumber = AlphNumberBox.Text;
var AlphNumbersArr = AlphNumber.ToCharArray(0,9);
char[] ConvNumbersArr = new char[10];

int i = 0;

foreach (var character in AlphNumbersArr; i++)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
}
}
would i need to change character to i
ACiDCA7
ACiDCA7•2mo ago
int i = 0;
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
i++;
}
int i = 0;
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
i++;
}
like this
Scrolly
Scrolly•2mo ago
Okay thanks I did not know i++ could be there at the bottom like that
ACiDCA7
ACiDCA7•2mo ago
sadly i dont have much time left so let me quickly type a few comments what to do and where to do maybe somene else can take over
int i = 0;
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
// so now you have checked cases when it is a letter but you still have to have to fill the array when it is not a letter

//do this with an else statement




i++;
}


//after you filled out the array you have to make astring out of it and then assign it to the textbox where it should appear
int i = 0;
foreach (var character in AlphNumbersArr)
{
if (char.IsLetter(character))
{
if (character == 'A' || character == 'B' || character == 'C')
{
ConvNumbersArr[i] = '2';
}
if (character == 'D' || character == 'E' || character == 'F')
{
ConvNumbersArr[i] = '3';
}
if (character == 'G' || character == 'H' || character == 'I')
{
ConvNumbersArr[i] = '4';
}
if (character == 'J' || character == 'K' || character == 'L')
{
ConvNumbersArr[i] = '5';
}
if (character == 'M' || character == 'N' || character == 'O')
{
ConvNumbersArr[i] = '6';
}
if (character == 'P' || character == 'Q' || character == 'R' || character == 'S')
{
ConvNumbersArr[i] = '7';
}
if (character == 'T' || character == 'U' || character == 'V')
{
ConvNumbersArr[i] = '8';
}
if (character == 'W' || character == 'X' || character == 'Y' || character == 'Z')
{
ConvNumbersArr[i] = '9';
}


}
// so now you have checked cases when it is a letter but you still have to have to fill the array when it is not a letter

//do this with an else statement




i++;
}


//after you filled out the array you have to make astring out of it and then assign it to the textbox where it should appear
`
Scrolly
Scrolly•2mo ago
Thank you very much for your time You have been greatly helpful 🙂 I think I got the worst of it down, thanks to you @ACiDCA7 are you available for a question really quick?
ACiDCA7
ACiDCA7•2mo ago
really quick
Scrolly
Scrolly•2mo ago
else if ((char.IsDigit(character)))
{
ConvNumbersArr[i] = (char)character;
}
else if ((char.IsDigit(character)))
{
ConvNumbersArr[i] = (char)character;
}
Would this be correct to determine if it is a digit and throw it into the array?
ACiDCA7
ACiDCA7•2mo ago
seems reasonable
Scrolly
Scrolly•2mo ago
Okay, thanks I am just really trying to understand the code, i apologize
ACiDCA7
ACiDCA7•2mo ago
asuming you dont have changed too much you could ignore additional checks if its digits/dashes since only letters should be converted and nothing else
Scrolly
Scrolly•2mo ago
Okay cool, thank you
ACiDCA7
ACiDCA7•2mo ago
so if letter convert else just add to your array
Scrolly
Scrolly•2mo ago
The dashes would cause some problems because it surpasses the character limit of 10 we set on the array right?
Want results from more Discord servers?
Add your server
More Posts