public class Animal
{
public void Eat()
{
Console.WriteLine("Animal eats for living.");
}
}
Animal a = new Animal();
is it really required to use new keyowrd when we instantiate an object ?
can we do like this
Animal a = Animal();
any help here would be great.
No. You can always use Activator – Activator.CreateInstance. Not sure if you would actually find it simpler than new though.
Also looking at your example, you probably want to make it static as your methods are not acting on a specific instance of your class. That ways you can directly call
Animal.Eat().