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());
}
}

Sachin SinghRank #66 · 26.2K reputationPosted Jun 27, 2021, 3:09 AM EDT
Pranam BhatRank #500 · 4.9K reputationPosted Jun 26, 2021, 12:49 PM EDT
public class Car : Vehicle
Valerie MeunierRank #1,526 · 1K reputationPosted Jun 26, 2021, 5:17 PM EDT
Pranam BhatRank #500 · 4.9K reputationPosted Jun 27, 2021, 1:15 AM EDT
Valerie MeunierRank #1,526 · 1K reputationPosted Jun 27, 2021, 3:58 AM EDT
Sonil KumarRank #3,343 · 430 reputationPosted Jul 30, 2021, 8:50 AM EDT