Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace scheduled_exe
{
    class Program
    {
        static void Main(string[] args)
        {
            myservicereference.Service ser = new myservicereference.Service();
            Console.WriteLine(ser.MethodName());Error comes here
            Console.ReadLine();
     


        }
    }
}


Errors :

Error 1 The best overloaded method match for 'System.Console.WriteLine(bool)' has some invalid arguments
Error 2 Argument 1: cannot convert from 'void' to 'bool'
Posted
Updated 2-Jan-14 10:12am
v5

What it tells me is that ser.MethodName() is returning a Boolean value not a string.

Though error 2 suggests that it isn't returning anything.
 
Share this answer
 
Comments
Ron Beyer 2-Jan-14 16:13pm    
It's only saying the first error because its the closest it can come to which overload he is trying to use. Since there is no overload for void, it just picks the first overload in the class, which is WriteLine(bool). The second error is what tells the story.
bowlturner 2-Jan-14 16:14pm    
I thought that might be the case, but wasn't positive.
Member 10499955 2-Jan-14 16:22pm    
Is there any other way to call this method?
bowlturner 2-Jan-14 16:24pm    
What is the definition of the method you are trying to call?
ser.MethodName() apparently returns a void, which you can't print. Its difficult to say since you didn't post the prototype for the webservice call.
 
Share this answer
 
v2
The problem that ser.MethodName() returns nothing (its has void), but WriteLine have something!!!
 
Share this answer
 
You ARE calling the MethodName method! The problem is it doesn't return anything and you're trying to print that!
 
Share this answer
 
v2
Comments
Member 10499955 2-Jan-14 16:41pm    
So this is Sub which isn't returning anything, how to call a sub. Sorry, If this seems dumb to you.
Dave Kreskowiak 2-Jan-14 16:58pm    
You already are! Just remove the Console.WriteLine crap surrounding it.
Dave Kreskowiak 2-Jan-14 16:59pm    
You SERIOUSLY need to to pick up a beginner's book on C# and work through it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900