Thursday, 30 December 2021

IQ

1. What is C#?

C# is an object-oriented, type-safe programming language developed by Microsoft, used mainly for building Windows, Web, and enterprise applications on the .NET platform.

2. Types of Comments in C#

 Single-line → `// comment`
 Multi-line → `/ comment /`
 XML Documentation → `/// comment`

3. Object in C#
An object is an instance of a class that occupies memory and represents real-world entities with state (fields) and behavior (methods).



4. What is the .NET Framework?

A software development platform by Microsoft that provides a runtime (CLR) and a class library for building and running applications.


5. Components of .NET

 CLR (Common Language Runtime)
 BCL (Base Class Library)
 ASP.NET
 ADO.NET
 WPF/WCF
 Languages (C#, VB.NET, F#)

6. What is OOP?

OOP (Object-Oriented Programming) is a paradigm based on Encapsulation, Inheritance, Polymorphism, and Abstraction.



7. Array vs ArrayList

 Array: Fixed size, stores same type, faster.
 ArrayList: Dynamic size, stores objects of different types, slower due to boxing/unboxing.



8. Control Statements in C#

 Conditional: `if`, `switch`
 Looping: `for`, `while`, `foreach`, `do-while`
 Jump: `break`, `continue`, `goto`, `return`



9. Classes in C#

A class is a blueprint for creating objects, containing fields, methods, properties, constructors, etc.



10. Abstract Class vs Interface in .NET

 Abstract class: Can have implementation + abstract members, supports inheritance.
 Interface: Only contracts (no implementation until C# 8 default methods). Supports multiple inheritance.



11. Constructors in C#

Special methods used to initialize objects. Types: Default, Parameterized, Copy, Static, Private constructors.



12. Assembly

A compiled code library in .NET (.dll or .exe) that contains metadata and IL code.



13. Private vs Public Assembly

 Private: Used by a single application (stored in app folder).
 Public (Shared): Used by multiple applications, stored in GAC.



14. MVC (Model-View-Controller)

 Model: Business/data logic.
 View: UI layer.
 Controller: Handles user input and communicates between model & view.



15. Languages supported by .NET

C#, VB.NET, F#, C++/CLI, IronPython, IronRuby, etc.



16. ViewBag vs ViewData

 ViewData: Dictionary, weakly typed, requires type casting.
 ViewBag: Dynamic property, easier to use, wrapper around ViewData.



17. Action Filters in ASP.NET MVC

Attributes that run before/after an action (e.g., `OnActionExecuting`). Used for logging, authorization, caching.



18. Authorize Filter vs Action Filter

 Authorize Filter: Specifically checks authentication/authorization.
 Action Filter: Can perform any pre/post logic (e.g., logging, validation).



19. Extension Methods

Static methods that add new functionality to existing types without modifying their source code.



20. async/await

Keywords used for asynchronous programming in C# to avoid blocking threads.



21. SOLID Principles

 S: Single Responsibility
 O: Open/Closed
 L: Liskov Substitution
 I: Interface Segregation
 D: Dependency Inversion



22. Dependency Injection

Design pattern where dependencies are injected at runtime instead of being created inside the class.



23. Singleton Design Pattern

Ensures a class has only one instance globally with a global point of access.



24. Delegates (Func, Predicate, Action)

 Func<T>: Returns a value.
 Action<T>: No return.
 Predicate<T>: Returns boolean.



25. Sealed Class

A class that cannot be inherited. Used for security and performance.



26. Caching Techniques

 In-memory cache
 Distributed cache (Redis)
 Output caching (ASP.NET MVC)



27. Using Statement in C#

Used for automatic disposal of resources (implements IDisposable).



28. GC.Collect vs Finalize vs Dispose

 GC.Collect(): Forces garbage collection.
 Finalize(): Called by GC before object destruction.
 Dispose(): Manually releases resources.



29. Token Generation Techniques

 Random values (UUID)
 JWT (HMAC/RSA)
 OAuth2 Tokens
 Time-based (OTP)



30. Code First vs DB First

 DB First: Model generated from DB (faster for existing DBs).
 Code First: Classes first, then DB (better for agile development).



31. Bundle Config & CDN

 Bundle Config: Combines/minifies CSS & JS for performance.
 CDN: Loads static files from distributed network servers.



32. Application Object vs Session Object

 Application: Shared across all users.
 Session: Specific to a single user.



33. IIS Request Processing

Request → HTTP.sys → IIS → ASP.NET pipeline → Handler → Response.



34. ref vs out

 ref: Must be initialized before passing.
 out: Must be assigned inside the method.



35. HTTP Status Codes

 200: OK
 403: Forbidden
 500: Internal Server Error



36. What is Render in ASP.NET?

Method that generates HTML from server controls and sends to client browser.



37. Web API Testing Techniques

 Postman, Swagger, Fiddler, NUnit, MSTest.



38. Web API vs WCF

 Web API: RESTful, JSON/XML, lightweight.
 WCF: SOAP, supports multiple protocols (TCP, HTTP).



39. Handle Exceptions without try-catch

 Global.asax Application\_Error
 Exception filters
 Middleware in ASP.NET Core



40. HTTP Verbs in Web API

 GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.



41. Contracts in WCF

Defines the service.

 Service Contract: Defines operations.
 Message Contract: Defines SOAP message structure.



42. Install Certificates in IIS

IIS Manager → Server Certificates → Import/Install → Bind to site.



43. Passport Authentication

Single sign-on service by Microsoft for authenticating users across multiple sites.



44. Web Service vs WCF

 Web Service: Only HTTP & SOAP.
 WCF: Multiple protocols (TCP, MSMQ, HTTP).



45. Web API Token Types

 JWT
 Bearer
 OAuth2 Access/Refresh Tokens



46. Where Configure Endpoints in WCF

Configured in Web.config/App.config under `<system.serviceModel>`.



47. XML vs JSON

 XML: Verbose, supports attributes/namespaces.
 JSON: Lightweight, faster, used in REST APIs.



48. Authentication & Authorization in Web API

 Authentication: Validates identity (who you are).
 Authorization: Validates permissions (what you can do).



49. CSRF Protection in Web API

 Anti-forgery tokens
 SameSite cookies
 Double-submit cookie technique



50. CORS in Web API

Enable with `[EnableCors]` attribute or middleware to allow cross-origin requests.



51. Authentication Filters in Web API

Custom filters to authenticate requests before hitting controllers.



52. Basic Authentication in Web API

Uses `Authorization: Basic <base64(username:password)>` header.



53. Forms Authentication

Uses cookies to store authenticated session ID.



54. Windows Authentication

Uses AD/NTLM/Kerberos credentials for intranet apps.



55. SSL in Web API

Configured via IIS bindings or `RequireHttpsAttribute` in MVC/Web API.

No comments:

Post a Comment