Recently, I encountered an error while creating a constructor in a derived class. The error and code is given below. Error: Error 1 ‘Hello_World.Customer’ does not contain a constructor that takes 0 arguments using System; namespace Hello_World { class Customer { public string _name; public Customer(string name) { _name = name; } public void PrintName()
Private access modifier in C# is only used when you want to use some type member within the containing type only and want to restrict it from accessing outside of the containing type. All type members are by default Private, so it is not necessary to use Private keyword in front of them. But it’s
Public access modifier is one of the 5 access modifiers in C#. Public access modifier is only used when you want to make any type member to be globally accessible within the containing type as well as outside of the containing type. An example of Public access modifier in C# is given below. using
In C#, access modifiers play a major role. They basically decide bounderies of your type and type members. Based on the access modifier, you can restrict access or allow access to any type or type member. There are 5 types of access modifiers. Public Private Protected Internal Protected Internal Type members like methods, fields, properties
Exceptions are unexpected errors generated by the CLR. It is very common that while executing your application you encounter some error and later you fix it by knowing the reason behind it. There are bunch of predefined exceptions in the DotNet framework like FileNotFound, DivideByZero, FormatException etc. However, name of these exceptions is pretty much