I am executing this simple program in which I am trying to see the outcome of Console.WriteLine
with function returning void given as an argument.
using System;
class Program
{
static void printMe()
{
}
static void Main(string[] args)
{
Console.WriteLine(printMe());
}
}
This is giving following error:
Program.cs(11,27): error CS1503: Argument 1: cannot convert from 'void' to 'bool' [C:\Users\Nafeez Quraishi\source\repos\X\X.csproj]
The build failed. Fix the build errors and run again.
As per the WriteLine documentation at https://learn.microsoft.com/en-us/dotnet/api/system.console.writeline?view=netframework-4.8 this looks to be corresponding to following case:
WriteLine(Object)
Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream.
Question is:
In order to write text representation of the function object returning void, why is it trying to covert it in to bool(than perhaps string)?