char[] to char

  • Thread starter Thread starter Gras666
  • Start date Start date
G

Gras666

Hi,

I'm trying to learn some basic encoding with c# for a command line
program and i have the following code:

static void Main(string[] args)
{
int a,b,d,z;
bool l;
string ba;
b=args.Length;
z=args.Length;
ba="Encoded: ";
for (a=0;a<b;a++)
{
char c = args[a].ToCharArray(); <- problem
d=0;
while (d<z)
{
c++;
d++;
}
z=z+z;
l=Random.Equals(3,20);
ba=ba + c + l.ToString();
}
Console.WriteLine(ba);
}

I get the error Cannot implicitly convert type 'char[]' to 'char'. How
can i change this?
 
char c = args[a].ToCharArray(); <- problem

You're getting a char array back and trying to put it into a single char.

char [] c = args[a].ToCharArray(); <- solution

This is going to cause you problems further down.

Andrew
 
Back
Top