Send email using smtp server.

We can send email using smtp server to any email address. We are using gmail smtp server to send email. For this we required Google username and password for authentication. If you want to send html text in body message than set IsBodyHtml property of MailMessage to true else false.

What are events in C#?

Events Events is a way for a class to provide notifications to clients of that class when some interesting things happens to an object. Events are declared using delegates. Events can only be invoked from within the class that declared them. Derived classes can not directly invoke events declared within the base class. To call Continue Reading…

Error executing child request for handler ‘System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper’.

This error occurred when you are calling a child action method. And that child View does not exists or have been moved to a new location. Here “Child” is the Action method name and “Home” is the controller name.

How to call child action method in Asp.Net MVC.

Child action methods can not be called directly. They have to call from inside of a view. We can make an Action method a child action method by decorating it with [ChildActionOnly] attribute. Calling child action method from inside of a view Where “Child” is the Action method name and “Home” is the controller name.

When to use var instead of type in C#.

Example 1 Here it is an optional to declare i as var type. Because we know the value is integer type. Example 2 it is also an optional to use var instead of string. Because we know all elements are string. Example 3 Use var when we have to deal with anonymous type data.

Difference between Abstraction and Encapsulation.

Abstraction Abstraction means hiding implementation. Abstraction can be achieved by interfaces or abstract classes. Abstraction focuses on the outside view of an object (i.e. the interface) TV Remote is the real world example of abstraction where we know little bit how to operate it. but does not know how they are implemented internally. Encapsulation Encapsulation Continue Reading…

Why multiple inheritance of classes is not supported in C#?

Multiple inheritance of classes is not supported in C# because of the diamond problem. Diamond Problem: If in a scenario there is a Class A have a Print method. And another classes B and C is overriding Class A Print method with single inheritance concept. Now we have a class D which inherit both these classes B Continue Reading…

Difference between Convert.ToString() and .ToString() method in C#.

Convert.ToString() method can handle null value and will not throw exception. Example: .ToString() method will throw exception (Object reference not set to an instance of an object.) while converting null value to string. Example: Exception : Object reference not set to an instance of an object.