A Tricky Interview Question about C#

Here is a tricky interview question: Please write output of following code and explain why? class Base : IDisposable { public Base() { Console.WriteLine(” Base Constructor”); } static Base() { Console.WriteLine(” Base Static Constructor”); } public void Dispose() { Console.WriteLine(” Base Dispose”); } ~Base() { Console.WriteLine(” Base Destructor”); } } class Derived : Base, IDisposable …

Read More

Linked List Implementation in C#

Linked List is an interesting topic that it is a special kind of list we can use. Reference: https://www.codeproject.com/Articles/1104980/Linked-List-Implementation-in-Csharp What is Linked List? Linked list is a linear data structure. It’s a collection of elements. Element is called as Node. Each element has value(data) and reference of next node. The very first node is called as Head and …

Read More

A Taste of ASP.NET Identity

Reference: https://channel9.msdn.com/Series/Customizing-ASPNET-Authentication-with-Identity/01 https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/introduction-to-aspnet-identity ASP.NET identity is a big topic. It’s quite complicated and sometimes hard to understand. Here is just a taste of ASP.NET identity. The ASP.NET identity core system is made up of Mangers and Stores. The Managers are high-level classes, and they can make some advanced operations such as create users. Just like …

Read More

A Dependency Injection and Repository Pattern Example – II

(continuing) Service Layer Here is another layer that we put advanced CRUD operation in it. The service layer will make use of repository layer to operate on the database, as well as be used by the controller to process the data. Here also firstly we define the interface IRoleService: namespace Cobra.App.Infrastructure.Contracts { public interface IRoleService …

Read More

Repository Pattern in ASP.NET

Reference: https://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application The Repository and Unit of Work Patterns The repository and unit of work patterns are intended to create an abstraction layer between the data access layer and the business logic layer of an application. Implementing these patterns can help insulate your application from changes in the data store and can facilitate automated unit testing …

Read More

The Usage of Ninject

Reference: By Adam Freeman – Pro ASP .NET MVC 4 4th Edition As has mentioned in the previous post, the idea of dependency injection is to decouple the components in our MVC applications. Here is the example that we will explain how to use the Dependency Injection Container–Ninject. The problem Our simple example project relies on tightly-coupled classes: the ShoppingCart class …

Read More