PC Review


Reply
Thread Tools Rate Thread

compiler error: cannot convert type void to string

 
 
puzzlecracker
Guest
Posts: n/a
 
      8th Oct 2008
I call method Foo(string s);

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

what's the deal here?
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gmail.com> wrote:
> 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
 
Reply With Quote
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 11:20 am, puzzlecracker <ironsel2...@gmail.com> wrote:
> 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") );
 
Reply With Quote
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 11:20 am, puzzlecracker <ironsel2...@gmail.com> wrote:
> 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
 
Reply With Quote
 
puzzlecracker
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 11:22*am, "Jon Skeet [C# MVP]" <sk...@pobox.com> wrote:
> On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gmail.com> wrote:
>
> > 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 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"); ?
 
Reply With Quote
 
Duggi
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 8:43*am, puzzlecracker <ironsel2...@gmail.com> wrote:
> On Oct 8, 11:22*am, "Jon Skeet [C# MVP]" <sk...@pobox.com> wrote:
>
>
>
> > On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gmail.com> wrote:

>
> > > 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 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
 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      8th Oct 2008
On Oct 8, 4:43*pm, puzzlecracker <ironsel2...@gmail.com> wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to convert a string representation of a type name into a Type object? Deckarep Microsoft C# .NET 6 18th Jun 2007 03:55 AM
How to convert System::String* (or System::Void) to void** in MC++? sovarschizsuzsa@gmail.com Microsoft VC .NET 2 11th Sep 2006 04:03 PM
Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login' keithb Microsoft ASP .NET 2 31st May 2006 08:21 PM
How can i convert to c#? (typedef void (*SWFByteOutputMethod) (byte b, void *data);) Michael Microsoft C# .NET 1 25th Mar 2005 09:02 AM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= Microsoft ASP .NET 2 26th Oct 2004 03:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:00 PM.