Showing posts with label asp.net interview questions. Show all posts
Showing posts with label asp.net interview questions. Show all posts

Monday, 5 July 2021

Difference between Abstract Class and Interface in C# | Abstract Class Vs Interface | OOPS concept| Abstraction and Inheritance

 

Abstract Class

Interface

An abstract class is a way to achieve the abstraction in C#.

The Abstract classes are typically used to define a base class in the class hierarchy.

An Abstract class is never intended to be instantiated directly.

This class must contain at least one abstract method, which is marked by the keyword or modifier abstract in the class definition.

Interface can have methods, properties, events, and indexers as its members. Interfaces will contain only the declaration of the members.

The implementation of interface’s members will be given by the class who implements the interface implicitly or explicitly.

Interface cannot be instantiated

The abstract keyword is used to declare abstract class.

The interface keyword is used to declare interface

Abstract class doesn't support multiple inheritance. A subclass can at most use only one abstract class

Interface supports multiple inheritance. A class can implement any number of interfaces

Abstract class can have abstract and non-abstract methods.

Interface can have only abstract methods.

An abstract class can declare or use any variables

Interfaces cannot contain fields.

An abstract class can have constructor declaration

Interfaces cannot contain constructors

It can contain static members.

It does not contain static members.

An abstract Class is allowed to have all access modifiers for all of its member declaration 

 In interface we can’t declare any access modifier (including public) as all the members of interface are implicitly public.

The performance of an abstract class is fast.

The performance of interface is slow because it requires time to search actual method in the corresponding class.

It is used to implement the core identity of class.

It is used to implement peripheral abilities of class.

If many implementations are of the same kind and use common behaviour, then it is superior to use abstract class.

If many implementations only share methods, then it is superior to use Interface.

Abstract class can contain methods, fields, constants, etc.

Interface can only contain methods.

It can be fully, partially or not implemented.

It should be fully implemented.

It contains both declaration and definition part

It contains only a declaration part.

Example:

public interface SampleInterface

    {

        void FirstMethod();

        string SecondName();

    }

Example:

abstract class SampleAbstractClass

    {

        int variable1 = 0;

        int variable2 = 1;

        public abstract void FirstMethod();

    }


Difference between abstract class and interface in C#




Friday, 18 June 2021

.NET Core and .NET Framework | Difference between .NET Core and .NET Framework | Comparison of .NET Core and .NET Framework | Advantages of .NET Core

Comparison of .NET Core and .NET Framework

Category

.NET Core

.NET Framework

Open source

.Net Core is an open source.

.NET Frame work is not open source. Some components are open source.

Cross-Platform

.NET Core is cross-platform, and supports three distinct operating systems — Windows, OS X, and Linux.

.NET Framework enabled developers to build applications for a single platform — Windows.

Application Models

.Net Core focuses more on Web, Windows Mobile, and Windows Store applications.
It does not support Desktopapplication development.

.Net Framework is used to build both Desktop as well as Web applications.
Windows Forms and WPF applications are very well supported.

Installation

.NET Core is packaged and installed independently of the underlying operating system as it is cross-platform.

.NET Framework is installed as a single package for Windows operating system.

Framework

.Net Core is a platform on top of which there are frameworks such as ASP .Net Core and Universal Windows Platform that leverage and extend the features of .Net Core.

.Net Framework is a full-fledged development framework. It provides UI, DB connectivity, Services, APIs, etc.

Performance and Scalability

.NET Core is more effective than .NET Framework to enhance the performance and scalability of applications. It enables developers to enhance the performance of applications drastically without deploying additional hardware or infrastructure. Also, it allows developers to build, test and deploy applications directly in the cloud. Hence, the developers can switch to .NET Core to enhance the performance and scalability of their applications without putting extra time and effort

.Net Framework is less effective in comparison to .Net Core in terms of performance and scalability of applicatio

Micro-Services

 .NET Core makes it easier for developers to build microservice oriented systems rapidly. .NET Core enables programmers to develop custom microservices by using varying programming languages, technologies and frameworks. Also, the developers can build a robust system by combining multiple microservices seamlessly.

.Net Framework does not support the development and implementation of microservices but it supports the REST API services.

Compatibility

.NET Core is compatible with various operating systems — Windows, Linux, and Mac OS. .NET Core does not support all the features and functionalities provided by the latest version of .NET Framework. But it can be used as a subset of the .NET Framework. 

.NET Framework is compatible only with the Windows operating system.

Packaging and Shipping

.Net Core is delivered as a set of NuGet packages. It has been factored, modularized and shipped as several NuGet packages.
Although the common runtime libraries are still a part of the bundle, the developer has the freedom to selectively include other libraries as per need. This makes .Net Core very lightweight. No extra baggage.

.Net Framework is packaged as a whole. All the libraries are bundled together and shipped together.

WCF/REST Services

.Net Core has no support for WCF services. You would always need to create a REST API.

.Net Framework is an excellent choice when WCF services are involved. It also supports REST services.

CLI Tools

.Net Core supports a very lightweight CLI for all platforms. There is always an option to switch to an IDE as well.

.Net Framework is too heavy for Command Line Interface.

Mobile App Development

.NET Framework does not include any robust framework or tools to simplify mobile app development.

.NET Core compatible with Xamarin through the .NET Standard Library. Hence, developers can take advantage of Xamarin to write cross-platform mobile apps in C# with a shared code base and same set of APIs. They can further use the tools provided by Xamarin to customize the mobile app for individual mobile platforms like iOS, Android and Windows Phone.

Cloud Ready Configuration

.NET Core is designed with features to simplify development and deployment of cloud-based application. 

It is not easy to deploy in cloud

Deployment Model

Whenever the updated version of .NET Core gets initiated; it is updated instantly on one machine at a time, thereby getting updated in new directories/folders in the existing application without affecting it. Thus, .NET Core has a good and flexible deployment model.

In the case of .Net Framework, when the updated version is released it is first deployed on the Internet Information Server only.

Standard Library

.NET Core implements version 1.6 of the .NET Standard Library.

s a formal specification of .NET APIs, the .NET Standard Library meets the requirements of varying runtimes and maintains uniformity in the .NET ecosystem. Each version of .NET Framework uses a specific version of .NET Standard Library. For instance, .NET Framework 4.6 implemented the .NET Standard Library 1.3

Modular Collection of Libraries

 .NET Core uses a redesigned common language runtime called CoreCLR, and features a modular collection of libraries called CoreFX. Hence, the developers have option to pick and use only the libraries required by each application, and enhance the application’s performance by removing unnecessary libraries.

.NET Framework and .NET Core allows developers to take advantage of robust class libraries.

.net framework vs .net core Difference between .NET Core and .NET Framework.  .NET Core is the new open-source and cross-platform framework to build applications for all operating system including Windows, Mac, and Linux.
.net framework vs .net core

Related Posts Plugin for WordPress, Blogger...

ShareThis