char[] to char

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?
 
A

amaca

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

char ----> int 12
char to string fails 3
h0w readkey works? 6
My own version of replace 21
Equals() and inheritance 7
Using Delegates? 2
DllIport and char** 2
how to test a char variable for null? 3

Top