compiler error: cannot convert type void to string

  • Thread starter Thread starter puzzlecracker
  • Start date Start date
I call method Foo(string s);

with Foo("foo"+"bar");

what's the deal here?

My guess is that you're doing something like:

string x = Foo("foo" + "bar");

If not, please show a short but complete program which demonstrates
the problem.

Jon
 
I call method Foo(string s);

with Foo("foo"+"bar");

what's the deal here?

post your complete code

I do nt know if you are doing
string s = Foo("foo"+"bar");
or
Foo( Foo("foo"+"bar") );
 
I call method Foo(string s);

with Foo("foo"+"bar");

what's the deal here?

In any case your method is returning void, it should be returning
string
 
My guess is that you're doing something like:

string x = Foo("foo" + "bar");

If not, please show a short but complete program which demonstrates
the problem.

Jon

I just call a method, with concatenation of two strings,that takes
string parameter. That's all.

BTW what is wrong with string x = Foo("foo" + "bar"); ?
 
I just call a method,  with concatenation of two strings,that takes
string parameter.  That's all.

BTW what is wrong with  string x = Foo("foo" + "bar"); ?

can you please post the signature of method please?

I guess it is

public/private void Foo(string)


-Cnu
 
I just call a method,  with concatenation of two strings,that takes
string parameter.  That's all.

I'm afraid I don't believe you. Please post a short but complete
program that demonstrates the problem.
BTW what is wrong with  string x = Foo("foo" + "bar"); ?

If Foo is declared to be void, then you can't assign a string variable
based on the result, because there isn't one.

Jon
 
Back
Top