Thursday, February 5, 2026

var vs dynamic

1.var

  • Type is decided at compile time

  • Strongly typed

  • Must be initialized at declaration

  • IntelliSense & compile-time checking available

Example

var x = 10;        // int
var name = "Ram"; // string

👉 If you assign a wrong type later → compile-time error


2.dynamic

  • Type is decided at runtime

  • Not strongly typed

  • No compile-time checking

  • Errors occur at runtime

Example

dynamic x = 10;
x = "Ram";        // allowed
x.DoSomething(); // runtime error if method not found

3.Key Differences (Interview Points)

Featurevardynamic
Type resolutionCompile timeRuntime
Type safetyYesNo
IntelliSenseYesNo
Error checkingCompile timeRuntime
Type change allowedNoYes

4.When to use?

  • Use var when type is obvious and you want clean code

  • Use dynamic when working with:

    • COM objects

    • Reflection

    • JSON / loosely typed data


5.Important interview one-liner

var is statically typed, dynamic is dynamically typed.


abstract class

1. What is an Abstract Class?

An abstract class is a partially implemented class.
It can have both abstract methods (no body) and normal methods (with body).

2. Key rule

  • An abstract class cannot be instantiated

  • It must be inherited by another class

3. What can an abstract class contain?

  • Abstract methods

  • Non-abstract (normal) methods

  • Fields

  • Properties

  • Constructors

4. Syntax example (interview-friendly)

abstract class Employee
{
    public abstract void Work();

    public void Login()
    {
        // common code
    }
}

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

5. Method implementation rule

  • Abstract methods must be overridden in the derived class

  • Normal methods are optional to override

6. Inheritance rule

  • Supports single inheritance only

  • Multiple inheritance is not allowed with classes

7. Abstract class vs Interface (short point)

  • Abstract class → Partial abstraction

  • Interface → Complete abstraction

8. Why do we use abstract classes?

  • To share common base functionality

  • To enforce base rules with flexibility

  • When some behavior is common and some is different

9. Important interview one-liner

An abstract class provides a base class with both implemented and unimplemented methods.


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

1. What is an Interface?

An interface is a contract.
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)

  1. Close Visual Studio completely

  2. Press Win + R

  3. Paste:

    %USERPROFILE%\AppData\Local\Microsoft\VisualStudio
  4. Open the required version folder (16.0 / 17.0)

  5. Delete these folders:

    • ComponentModelCache

    • Cache

    • Roslyn (optional)

  6. 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 to 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:
  1. Close Visual Studio.
  2. Open File Explorer → navigate to your project folder.
  3. Delete the folders:
    bin\Debug obj\Debug
  4. Reopen 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 Run
  • Set “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).