Different Types of Constructors in C#

A constructor is a method in the class which gets executed when its object is created. A constructor is usually used to initialize data members of the class. There are four different types of constructors: Default Constructor When you do not declare any constructor, the class will call its default constructor. The default constructor is a parameter …

Continue reading Different Types of Constructors in C#

Advertisements

How can you find a control in an ASP.NET page from code behind

Lets suppose we have an ASP.NET page and we have the following control in it: <asp:Label runat="server" ID="label1"></asp:Label> To find the control in the page from code behind, you have to do the following: Label lbl = this.FindControl("label1") as Label; This will work in any normal ASP.NET page, but will not work if you using a Master …

Continue reading How can you find a control in an ASP.NET page from code behind

Generics

The need to create class that can work with any type of data is increasing. Generics allow you to define type-safe data structures, without committing to actual data types. By using Generics, you get to reuse data processing algorithms without duplicating type-specific code. Generics, when compared to inheritance, can increase type safety and reduce casting and boxing. Generic …

Continue reading Generics

What is the difference between arrays and collection?

Array: You need to specify the size of an array at the time of its declaration. It cannot be resized dynamically. The members of an array should be of the same data type. Collection: The size of a collection can be adjusted dynamically, as per the user's requirement. It does not have fixed size. Collection …

Continue reading What is the difference between arrays and collection?

URL Routing in ASP.NET 4

Normally when you access a web page, you use a URL that is the physical path of the page. URL routing is a way to provide your own URL instead of the physical path. ASP.NET 4.0 provides us with a simple and strong way to handle URL routing. ASP.NET 4.0 router enables to define any …

Continue reading URL Routing in ASP.NET 4