Posts

Showing posts from September, 2024

All remaining Dotnet Developer Interview questions and answers which I was facing

Here are the answers for the remaining questions: 14. Multiple Return Types from a Method Answer: You can return multiple values from a method using Tuple, out parameters, or a custom object. Example using Tuple: public (int, string) GetMultipleValues() {     return (1, "Result"); } var result = GetMultipleValues(); Console.WriteLine($"ID: {result.Item1}, Value: {result.Item2}"); --- 15. Private Constructor Answer: A private constructor is used to prevent the instantiation of a class from outside the class. It’s typically used in singleton patterns. Example: public class MyClass {     private MyClass() { }  // Private constructor } --- 16. Method Hiding Answer: Method hiding occurs when a method in a derived class has the same name and signature as one in its base class but is marked with the new keyword. This hides the base class implementation. Example: public class BaseClass {     public void Display() { Console.WriteLine("Base Display"); } } public...

Dotnet Interview questions and answers real time Which I am facing

Here are detailed answers to some of the questions you asked: 1. Async Method Execution Time Question: If MethodA starts at 11:00, when will it return true? Answer: The time when MethodA returns depends on the execution times of MethodB and MethodC. Since both methods are awaited, MethodA will return true only after both MethodB and MethodC complete. If MethodB and MethodC take 5 seconds each, then MethodA will return true after 10 seconds (i.e., at 11:00:10). --- 2. LINQ Query to Get Top 3 Salaries Department-wise SQL Query: SELECT Department.name, emp.id, emp.name, emp.salary FROM Employee emp JOIN Department ON emp.depid = Department.depid WHERE emp.salary IN (SELECT TOP 3 salary FROM Employee e WHERE e.depid = emp.depid ORDER BY salary DESC) ORDER BY Department.name, emp.salary DESC; LINQ Query: var result = context.Employees              .GroupBy(e => e.DepartmentId)              .SelectMany(g => g.OrderByD...

Top 10+ Interview questions and answers for dotnet developer experience and fresher

Top 10+ Here are detailed answers to some of the questions you asked: 1. Async Method Execution Time Question: If MethodA starts at 11:00, when will it return true? Answer: The time when MethodA returns depends on the execution times of MethodB and MethodC. Since both methods are awaited, MethodA will return true only after both MethodB and MethodC complete. If MethodB and MethodC take 5 seconds each, then MethodA will return true after 10 seconds (i.e., at 11:00:10). 2. LINQ Query to Get Top 3 Salaries Department-wise SQL Query: SELECT Department.name, emp.id, emp.name, emp.salary FROM Employee emp JOIN Department ON emp.depid = Department.depid WHERE emp.salary IN (SELECT TOP 3 salary FROM Employee e WHERE e.depid = emp.depid ORDER BY salary DESC) ORDER BY Department.name, emp.salary DESC; LINQ Query: var result = context.Employees              .GroupBy(e => e.DepartmentId)              .SelectMany(g => g.Orde...

Top Dotnet Developer Interview questions and answers for experience and fresher

Top Dotnet Developer Interview questions and answers  Entity Framework Questions 1. What is History Table in EF? Answer: In EF Core, a history table is created automatically when you enable auditing or track changes in tables. It stores previous versions of rows when they are updated or deleted, providing an audit trail. Example: You can implement it using Temporal Tables in SQL Server with EF Core 6+. 2. Migrate and Execute a SQL Script in EF Answer: Yes, you can use EF Core migrations to apply a SQL script. EF allows custom SQL commands in migrations. Example: migrationBuilder.Sql("CREATE PROCEDURE MyProcedure AS BEGIN SELECT * FROM Employees END"); 3. Selecting Data from Multiple Tables in EF Answer: You can use Join in LINQ to select data from multiple tables. Example: var result = from emp in context.Employees              join dept in context.Departments on emp.DepartmentId equals dept.Id              selec...

Angular Interview questions and answers

how to implement Observables, Promises, Lazy Loading, and Eager Loading in Angular: 1. Observable in Angular Definition: An Observable is used for handling asynchronous data streams where multiple values can be emitted over time. Implementation: import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; @Component({   selector: 'app-observable-demo',   template: `<div>{{ data | async }}</div>`, }) export class ObservableDemoComponent implements OnInit {   data: Observable<string>;   ngOnInit() {     this.data = new Observable((observer) => {       setTimeout(() => observer.next('Observable Data 1'), 1000);       setTimeout(() => observer.next('Observable Data 2'), 2000);       setTimeout(() => observer.complete(), 3000);     });   } } In this example, the data observable emits values over time, and the | async pipe in the template automatical...

How Abstract works in C#

How Abstraction Works in C# In C#, an abstract class is a class that cannot be instantiated directly. It is used as a blueprint for other classes. An abstract method has no body and must be implemented by any non-abstract derived class. Key Points: Abstract Class: Cannot be instantiated directly and can have both abstract and non-abstract methods. Abstract Method: Declared in an abstract class without a body. Derived classes must provide an implementation for this method. Example: Abstraction with Inheritance in C# // Abstract class public abstract class Shape {     // Abstract method (no implementation here)     public abstract double CalculateArea();          // Non-abstract method     public void DisplayInfo()     {         Console.WriteLine("This is a shape.");     } } // Derived class for Circle public class Circle : Shape {     public double Radius { get; set; }     /...

Design Patterns in C#

Please look for more about Design Patterns in C# https://youtube.com/shorts/XWUlSmxUApg?si=tew3EcdEUdFlDwJo #dotnetechpro #dotnet #csharp #DesignPattern

Solid principles in C#

🎯 Mastering SOLID Principles in C# 💻 Understanding SOLID principles is essential for writing clean, maintainable, and scalable code. Here's a quick rundown: 1️⃣ S - Single Responsibility Principle: A class should have one and only one reason to change. 🔑 Keep it focused on a single task. 2️⃣ O - Open/Closed Principle: Classes should be open for extension, but closed for modification. 🔑 Extend functionality without changing existing code. 3️⃣ L - Liskov Substitution Principle: Subtypes must be substitutable for their base types. 🔑 Derived classes should uphold the behavior expected by their parent classes. 4️⃣ I - Interface Segregation Principle: Clients should not be forced to depend on interfaces they don’t use. 🔑 Split interfaces into smaller, more specific ones. 5️⃣ D - Dependency Inversion Principle: High-level modules should not depend on low-level modules. Both should depend on abstractions. 🔑 Use interfaces or abstract classes to decouple code. Implementing these prin...