Monday, August 24, 2020

Can abstract class have constructor?

Yes, Abstract Classes can have constructors!

An abstract class can have a constructor though it cannot be instantiated. But the constructor defined in an abstract class can be used for the instantiation of a concrete class of this abstract class.

Can you have a static method in a non static class?

You can define one or more static methods in a non-static class. Static methods can be called without creating an object. You cannot call static methods using an object of the non-static class.

Friday, August 21, 2020

What are the differences between REST and SOAP?

 

  1. SOAP stands for Simple Object Access Protocol whereas REST stands for Representational State Transfer.
  2. The SOAP is an XML based protocol whereas REST is not a protocol but it is an architectural pattern i.e. resource-based architecture.                         
  3. SOAP has specifications for both stateless and state-full implementation whereas REST is completely stateless.
  4. SOAP enforces message format as XML whereas REST does not enforce message format as XML or JSON.
  5. The SOAP message consists of an envelope which includes SOAP headers and body to store the actual information we want to send whereas REST uses the HTTP build-in headers (with a variety of media-types) to store the information and uses the HTTP GET, POST, PUT and DELETE  methods to perform CRUD operations.
  6. SOAP uses interfaces and named operations to expose the service whereas to expose resources (service) REST uses URI and methods like (GET, PUT, POST, DELETE).

  7. SOAP Performance is slow as compared to REST.

.net core and .net framework difference

Developers use the. NET framework to create Windows desktop applications and server-based applications. This includes ASP.NET web applications. NET Core is used to create server applications that run on Windows, Linux, and Mac.

SingleorDefault vs Firstordefault example

Single

It returns a single specific element from a collection of elements if the element match found. An exception is thrown, if none or more than one match found for that element in the collection.


SingleOrDefault

It returns a single specific element from a collection of elements if the element match found. An exception is thrown if more than one match found for that element in the collection. The default value is returned, if no match is found for that element in the collection.


First

It returns the first specific element from a collection of elements if one or more than one match found for that element. An exception is thrown, if no match is found for that element in the collection.


FirstOrDefault

It returns the first specific element from a collection of elements if one or more than one match found for that element. The default value is returned, if no match is found for that element in the collection.


Tuesday, August 18, 2020

When to use Interface?

 If your child classes should implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.

Sunday, August 16, 2020

When to use Abstract Classes in C#?

 When we have a requirement where our base class should provide the default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.

Friday, August 14, 2020

How can you detect the client's browser name?

 You can use the navigator. appName and navigator. userAgent properties.

C# Destructor Syntax

 class User

    {

        // Destructor

        ~User()

        {

            // your code

        }

    }

Thursday, August 13, 2020

visual studio component model cache clear

 %localappdata%\Microsoft\VisualStudio\ -- Goto 12.0 or particular visual studio 14.0 delete component cache model inside folders.