Thursday, February 5, 2026

Interface - An interface defines what to do, not how to do it.

1. What is an Interface?
An interface is a contract.
It defines 
It defines what methods or properties a class must have, but not the implementation.

2. What can an interface contain?
Method declarations
Properties
Events
👉 No method body (before C# 8.0)

3. How do we use an interface?
A class implements an interface
The class must implement all methods of the interface

4. Syntax example (interview-friendly)
interface IEmployee
{
void Work();
}

class Developer : IEmployee
{
public void Work()
{
// implementation
}
}

5. Multiple inheritance support
C# does not support multiple inheritance with classes
But a class can implement multiple interfaces
class MyClass : IInterface1, IInterface2
{
}

6. Interface vs Abstract Class (short point)
Interface → 100% abstraction
Abstract class → Partial abstraction

7. Why do we use interfaces?
Loose coupling
Dependency Injection
Multiple inheritance
Better maintainability and testability

8. Important interview one-liner
An interface defines what to do, not how to do it.

How to Find Repeated Values in Excel Using COUNTIF

To identify repeated values in Excel,

after adding a new column for count,

after typing =COUNTIF(, come to the left arrow and move to the required column. After that, press Ctrl + Shift + End to go till the end. Then, put a comma. Next, press Ctrl + Shift + Up Arrow to come to the beginning of the column. After coming there, click Enter, then the result will come. If you drag the result, the output will come for all columns.

=COUNTIF(A2:A248,A2) - example 

Wednesday, January 7, 2026

How to Clear Visual Studio Cache || Visual Studio Component Cache Location

Visual Studio Component Cache Location
Main Path (User-specific)
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
Inside this folder, you will see version-specific folders like:
16.0_xxxxxx → Visual Studio 2019
17.0_xxxxxx → Visual Studio 2022

Common Cache Folders You Can Clear
ComponentModelCache (Most important)
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\16.0_xxxxxx\ComponentModelCache
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\17.0_xxxxxx\ComponentModelCache
Clearing this fixes:
Visual Studio slowness
IntelliSense issues
Extension load errors

MEF Cache
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\16.0_xxxxxx\Cache

Roslyn Cache (C# / IntelliSense)
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\17.0_xxxxxx\Roslyn

Designer Shadow Cache
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\Designer

How to Clear Visual Studio Cache (Safe Steps)
Method 1: Manual (Recommended)
Close Visual Studio completely
Press Win + R
Paste:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
Open the required version folder (16.0 / 17.0)
Delete these folders:
ComponentModelCache
Cache
Roslyn (optional)
Restart Visual Studio
Cache will be recreated automatically

Method 2: Command Prompt
devenv /clearcache
Run from Developer Command Prompt for Visual Studio

What NOT to Delete
Do NOT delete:
Extensions folder
Settings files
.vs folder inside your solution (unless troubleshooting)


Thursday, December 4, 2025

If you want the list of databases currently being used / active connections

 SELECT 
    DB_NAME(database_id) AS DatabaseName,
    COUNT(*) AS ActiveConnections
FROM sys.dm_exec_sessions
WHERE database_id > 0
GROUP BY database_id
ORDER BY ActiveConnections DESC;

If you want BOTH list of customer DBs + active connections
SELECT 
    d.name AS DatabaseName,
    ISNULL(c.ActiveConnections, 0) AS ActiveConnections
FROM sys.databases d
LEFT JOIN (
    SELECT database_id, COUNT(*) AS ActiveConnections
    FROM sys.dm_exec_sessions
    GROUP BY database_id
) c ON d.database_id = c.database_id

WHERE d.name LIKE 'C%';

Friday, October 31, 2025

Could not copy "obj\Debug\etc" to "obj\Debug\etc". Exceeded retry count of 10. Failed.


 1. Stop the Running Application
Make sure your app (yourapp(ur application name)) is not running.
Open Task Manager (Ctrl+Shift+Esc) → go to Details tab.
Find yourapp(ur application name)) → End Task.
Rebuild your project.

2. Clean and Rebuild
In Visual Studio:
Go to Build → Clean Solution
Then Build → Rebuild Solution
This clears the obj and bin folders and rebuilds everything fresh.

3. Check for Debugger/Antivirus Locks
Sometimes, even if the EXE isn’t running:
Antivirus software may be scanning or locking the file — temporarily disable real-time protection or add your project folder toa exceptions.
Visual Studio Debugger might not have released the file — close the solution and reopen it.

4. Manually Delete Locked Files
If the above doesn’t work:
Close Visual Studio.
Open File Explorer → navigate to your project folder.
Delete the folders:
bin\Debug
obj\DebugReopen Visual Studio → Rebuild.
If Windows says “file is in use,” use a tool like Process Explorer:
Download from Microsoft Sysinternals.Search for (yourapp(ur application name)) → right-click → Kill Process.

5. Disable Parallel Builds (Optional)
If your solution has multiple projects:
Go to Tools → Options → Projects and Solutions → Build and RunSet “maximum number of parallel project builds” = 1
This avoids concurrent file access issues.

6. Check Post-Build Events
If you have a post-build script that copies or runs the EXE, ensure it’s not launching the app before the next build.

Monday, October 13, 2025

How to download (clone) a Git repository into a specific folder ?

If you want to download (clone) a Git repository into a specific folder, you can do it very easily using the git clone command with a folder path at the end. 

Option 1 – Clone directly into a specific folder Command format: git clone 
Example: git clone https://github.com/username/Notes.git D:\Projects\NotesApp 

This will: Download the Git repository into the folder D:\Projects\NotesApp If the folder doesn’t exist, Git will create it automatically. 

Option 2 – Clone in current folder with custom name. If you’re in a directory (e.g. D:\Projects) and you want to clone the repo into a subfolder with a custom name, do this: 

cd D:\Projects (Enter)

git clone https://github.com/username/Notes.git 

MyNotes It will create a folder called MyNotes inside D:\Projects and put the repo code there.

Thursday, August 21, 2025

Get Location

Your Location

Getting location...

Thursday, May 22, 2025

XML declaration.

<?xml version="1.0" encoding="utf-8"?> 

This is the XML declaration.

version="1.0": Tells the XML parser to use version 1.0 rules.

encoding="utf-8": Says the text is encoded in UTF-8 (supports all languages and symbols).

Wednesday, April 23, 2025

Authentication and Authorization:

What is Authentication? 
 Authentication is the process of verifying who the user is. 
 - In ASP.NET MVC, authentication means checking if the user is logged in or not. 
 - It ensures that the user is genuine and valid. 
 - Common methods: Forms Authentication, Windows Authentication, OAuth, etc. 
 Example: When a user logs in using a username and password, the application verifies those credentials — this is authentication. 
 ---------------------------------------------------------------------------------------------------------------------------
 What is Authorization? 
 Authorization is the process of checking what the authenticated user is allowed to do. 
 - It decides what resources or actions the user can access. 
 - In MVC, we use [Authorize] attribute to restrict access to certain actions or controllers. 
 Example: After login, if only Admins can access the "Admin Panel", that check is done using authorization. 
 ----------------------------------------------------------------------------------------------------------------------------
 Simple Difference:
 | Feature                       | Authentication                        | Authorization 
-------------------------- --|--------------------------------- --|--------------------------------- 
 Meaning                       | Who are you?                         | What can you do?  
Comes First                   | Yes                                         | After authentication  
Purpose                          |Verify identity                        | Grant access       
ASP.NET MVC Tool     | FormsAuth, Identity, OAuth | [Authorize], Roles, Policies  

 --- Bonus Tip for Interview: > “Authentication checks identity, Authorization checks permissions. You must  authenticate first, then authorize.”

Thursday, February 27, 2025

C# differences


# Concept Comparison Example
1 Abstract Class vs Interface Abstract class can have implementations; interface cannot. abstract class A {} vs interface I {}
2 Ref vs Out ref requires initialization, out does not. void Method(ref int x) vs void Method(out int x)
3 Value Type vs Reference Type Value types store data directly; reference types store memory addresses. int x = 5; vs string s = "Hello";
4 == vs Equals() == checks reference for objects, Equals() checks values. "abc" == "abc" vs "abc".Equals("abc")
5 Sealed vs Static vs Abstract Class sealed prevents inheritance, static prevents instantiation, abstract enforces method overriding. sealed class A {}, static class B {}, abstract class C {}
6 Method Overloading vs Overriding Overloading is same method with different parameters; Overriding modifies base method. void Show(int x) vs override void Show()
7 Stack vs Queue Stack: LIFO, Queue: FIFO. Stack<int> stack = new Stack<int>();
8 Stack vs Heap Stack stores value types; Heap stores reference types. int x = 10; (Stack) vs new Person(); (Heap)
9 IEnumerable vs IQueryable IEnumerable executes in-memory, IQueryable executes on the database server. IEnumerable<T> (Linq in-memory) vs IQueryable<T> (Linq-to-SQL)
10 String vs StringBuilder string is immutable, StringBuilder is mutable. string s = "Hello"; vs StringBuilder sb = new();
11 Task vs Thread Task is for async programming, Thread is for parallel execution. Task.Run(() => {...}) vs new Thread(()=> {...}).Start();
12 ReadOnly vs Const vs Static const is compile-time, readonly is runtime, static belongs to class. readonly int a;, const int b = 10;, static int c;
13 Dispose vs Finalize Dispose() is called explicitly; Finalize() is called by GC. using(obj) {...} vs ~ClassName()
14 Early Binding vs Late Binding Early binding is compile-time; Late binding is runtime. var obj = new Class(); (early) vs dynamic obj = new Class(); (late)
15 XML vs JSON XML uses tags, JSON uses key-value pairs. <Person><Name>John</Name></Person> vs {"Name": "John"}
16 Static Constructor vs Instance Constructor Static runs once per class; instance runs per object. static Example() {} vs public Example() {}
17 DataSet vs DataReader DataSet stores data in memory; DataReader reads forward-only. DataSet ds = new DataSet(); vs SqlDataReader dr = cmd.ExecuteReader();
18 Hashtable vs Dictionary Dictionary<T, T> is type-safe; Hashtable is not. Dictionary<int, string> d = new();
19 Struct vs Class struct is value type; class is reference type. struct Point {} vs class Point {}
20 Interface vs Delegate Interface defines behavior; Delegate is a method reference. interface IRun {} vs delegate void MyDelegate();
21 IS vs AS Operator is checks type compatibility; as performs safe casting. if (obj is string) vs string s = obj as string;
22 Singleton vs Static Class Singleton allows only one instance; Static class cannot be instantiated. private static Singleton instance; vs static class MyClass {}
23 Lazy Loading vs Eager Loading Lazy loads data when needed; Eager loads immediately. Lazy<T> obj = new Lazy<T>();
24 Throw vs Throw ex throw preserves stack trace, throw ex resets it. throw; vs throw ex;
25 Partial Class vs Abstract Class Partial splits a class, Abstract enforces overriding. partial class MyClass {} vs abstract class MyClass {}
26 Deep Copy vs Shallow Copy Deep Copy creates a new object, Shallow Copy copies reference. Clone() for Deep, MemberwiseClone() for Shallow
27 Boxing vs Unboxing Boxing converts value type to object, Unboxing retrieves value type from object. object obj = 10; (Boxing) vs int x = (int)obj; (Unboxing)
28 Implicit vs Explicit Conversion Implicit is automatic; Explicit requires casting. int x = 10; double d = x; vs double d = 10.5; int x = (int)d;
29 Delegate vs Event Delegate is a function pointer, Event is a restricted delegate. delegate void MyDelegate(); vs event MyDelegate MyEvent;
30 Thread vs Process Thread is lightweight; Process is heavyweight. Thread t = new Thread(); vs Process p = new Process();