Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 84.4k

can not be applied for string and void

Jun 26 2021 4:45 PM

Hi

I ger the error :"can not be applied for string and void". Any way to fix it?

auto.Horn() works, but i want it into Console.WriteLine.

Thanks

using System;
class Vehicle
{
    public virtual void Horn()
    {
        Console.WriteLine("horn in general");
    }
}

class Car : Vehicle
{
    public override void Horn()
    {
        Console.WriteLine("horn of car does tuut!");
    }
}

class Head

     static void Main(string[] args)
{
    Car auto = new Car();
    Console.WriteLine("Horn does " + auto.Horn());
}
}


Answers (6)