char to string fails

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

char[] ch = new char[1];

ch[0]="-";

FileStream fp=new FileStream("z:\\" + "math" + ch[0].ToString() +
"optpivot",FileMode.Open,FileAccess.Read);



Why does this fail with Cannot implicitly convert type 'string' to 'char'
(CS0029) ?

Best

David
 
double quotes indicate string type, single quotes indicate char type
so try:

ch[0] = '-';
 
David,

It's this line:

ch[0]="-";

It should be:

ch[0]='-';

Note the single quotes which are used to indicate a character literal.
 

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

Back
Top