I'm using C# 6.0 in VS Community
Where event initializers removed from c# 6.0 & any idea why the code below doesn't work?
Where can I get an updated list of not just latest features and what was recently removed from C# 6.0?
This doesn't compile for me. Specifically on line with 'Barking += (o, e)...'
EventHandler<EventArgs> log = (o, e) => Console.Write("woof");
var dog = new Dog()
{
Age = 3,
Barking += (o, e) => Console.Write("woof");
};
class Dog
{
public void Bark() {
if (Barking != null) {
Barking(this,new EventArgs());
}
}
public int Age { get; set; } = 0;
public string Name { get; set; } = "nameless";
public event EventHandler<EventArgs> Barking;
}
Any help would be appreciated, please.