I'm working on a C# program to scrub extended ASCII characters (examples are in my input string) from a series of text files. Here's what I'm running into. While I can recast the char as Int32 in my for loop, I'm trying to see if there's any way, to re-cast the array as Int32 values? In a perfect world, I'd like to pass an Int32 array of rocessing methods directly. Right now, I'm planning on just creating a method that takes the char array and returns an Int32 array. Is there an easier way to do this that would be similar to the comment I've included in my code?
string value = "Slide™1½”C4®";
byte[] asciiValue = Encoding.ASCII.GetBytes(value); // byte array
char[] array = value.ToCharArray(); // char array
/*
is there something like
Int32[] int32Array = array[].ToInt32();
*/
Console.WriteLine("CHAR\tBYTE\tINT32");
for (int i = 0; i < array.Length; i++) {
char letter = array[i];
byte byteValue = asciiValue[i];
Int32 int32Value = array[i];
/*
... evaluate int32Value and do stuff ...
*/
Console.WriteLine("{0}\t{1}\t{2}", letter, byteValue, int32Value);
}
Console.ReadLine();
My plan B:
private Int32[] RecastCharArray(char[] array)
{
Int32[] int32Value ;
for (int i = 0; i < array.Length; i++) {
int32Value[i] = array[i];
}
return int32Value;
}