3
//Esse código tem o objetivo de substituir uma letra por um código
string usuario = Environment.UserName;
string palavra = usuario.ToLower();
int tamanho_array = palavra.Length;
var array = new string[tamanho_array];
for (int i = 0; i < array.Length; i++)
{
array[i] = palavra[i].ToString();
}
tamanho_array++;
int n = 0;
string saida = "";
while (n != tamanho_array){
if(array[n] == "a"){saida += "-01100001-";};
if(array[n] == "b"){saida += "-01100010-";};
if(array[n] == "c"){saida += "-01100011-";};
if (array[n] == "d"){saida += "-01100100-"; };
if (array[n] == "e"){saida += "-01100101-"; };
if (array[n] == "f"){saida += "-01100110-"; };
if (array[n] == "g"){saida += "-01100111-"; };
if (array[n] == "h"){saida += "-01101000-"; };
if (array[n] == "i"){saida += "-01101001-"; };
if (array[n] == "j"){saida += "-01101010-"; };
if (array[n] == "k"){saida += "-01101011-"; };
if (array[n] == "l"){saida += "-01101100-"; };
if (array[n] == "m"){saida += "-01101101-"; };
if (array[n] == "n"){saida += "-00001010-"; };
if (array[n] == "o"){saida += "-01101111-"; };
if (array[n] == "p"){saida += "-01110000-"; };
if (array[n] == "q"){saida += "-01110001-"; };
if (array[n] == "r"){saida += "-01110010-"; };
if (array[n] == "s"){saida += "-01110011-"; };
if (array[n] == "t"){saida += "-01110100-"; };
if (array[n] == "u"){saida += "-01110101-"; };
if (array[n] == "v"){saida += "-01110110-"; };
if (array[n] == "w"){saida += "-01110111-"; };
if (array[n] == "x"){saida += "-01111000-"; };
if (array[n] == "y"){saida += "-01111001-"; };
if (array[n] == "z"){saida += "-01111010-"; };
if (array[n] == "."){saida += "-00101110-"; };
n++;
}
Exit "-01100001-01101100-01100101-01111000-" If the user is "Alex" but the copier returns the error The index was outside the matrix boundaries (System.Indexoutofrangeexception) and I inspected and the array is filled with the user name correctly.
Here it worked out thank you very much, as I did not see it? hahaha.
– Gabr13l_Alm31da
@Gabr13l_alm31da relaxes, it comes with time, the more you do but you see these mistakes faster ^^.
– João Paulo Amorim