Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Day: July 11, 2026

C#

C#: Struct vs Class โ€” Choose Wisely

- 11.07.26 - ErcanOPAK comment on C#: Struct vs Class โ€” Choose Wisely

๐Ÿ“ฆ Struct vs Class โ€” Choose Wisely Both store data. Struct vs Class matters for performance. Value type vs reference type. ๐Ÿ“ Key Differences // Class (Reference Type) public class Person { public string Name { get; set; } public int Age { get; set; } } // Struct (Value Type) public struct Point { […]

Read More
C#

C#: Async/Await Best Practices

- 11.07.26 - ErcanOPAK comment on C#: Async/Await Best Practices

โšก Async/Await Best Practices Async is powerful but tricky. Best practices make it reliable. Performance, deadlocks, error handling. ๐Ÿ“ Best Practices // 1. Use async for I/O only // Good: Database, HTTP, file I/O public async Task GetUserAsync(int id) { … } // Bad: CPU-intensive operations public async Task CalculateAsync(int n) { … } // […]

Read More
SQL

SQL: Master Joins for Data Relationships

- 11.07.26 - ErcanOPAK comment on SQL: Master Joins for Data Relationships

๐Ÿ”— Joins = Data Relationships Data is in multiple tables. Joins combine them. INNER, LEFT, RIGHT, FULL โ€” choose right. ๐Ÿ“ Join Types — INNER JOIN (Only matching) SELECT u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id; — LEFT JOIN (All from left) SELECT u.name, o.total FROM users u LEFT […]

Read More
Asp.Net Core

.NET Core: Use Output Caching for Performance

- 11.07.26 - ErcanOPAK comment on .NET Core: Use Output Caching for Performance

โšก Output Caching = Performance Repeated requests are wasteful. Output caching saves results. Faster responses, lower server load. ๐Ÿ“ Output Caching Setup // Install package dotnet add package Microsoft.AspNetCore.OutputCaching // Program.cs builder.Services.AddOutputCache(options => { options.AddBasePolicy(builder => { builder.Expire(TimeSpan.FromMinutes(10)); }); options.AddPolicy(“ShortCache”, builder => { builder.Expire(TimeSpan.FromSeconds(30)); }); options.AddPolicy(“LongCache”, builder => { builder.Expire(TimeSpan.FromHours(1)); }); options.AddPolicy(“VaryByQuery”, builder => { […]

Read More
Git

Git: Use Revert to Undo Commits Safely

- 11.07.26 - ErcanOPAK comment on Git: Use Revert to Undo Commits Safely

โ†ฉ๏ธ Git Revert = Safe Undo Mistakes happen. Git revert undoes commits safely. No history rewrite, safe for shared branches. โŒ git reset (Dangerous) git reset –hard HEAD~1 // Rewrites history โœ… git revert (Safe) git revert HEAD // Creates new commit undoing changes ๐Ÿ“ Revert Commands # Revert last commit git revert HEAD # […]

Read More
Ajax

Ajax: Use WebSockets in .NET Core

- 11.07.26 - ErcanOPAK comment on Ajax: Use WebSockets in .NET Core

๐Ÿ”Œ WebSockets in .NET Core Real-time is essential. WebSockets in .NET Core enable bidirectional communication. ๐Ÿ“ WebSocket Setup // Program.cs var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.UseWebSockets(); app.Map(“/ws”, async context => { if (context.WebSockets.IsWebSocketRequest) { using var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await HandleWebSocket(webSocket); } else { context.Response.StatusCode = 400; } }); async Task […]

Read More
JavaScript

JavaScript: Use Nullish Coalescing (??) for Defaults

- 11.07.26 - ErcanOPAK comment on JavaScript: Use Nullish Coalescing (??) for Defaults

?? Nullish Coalescing = Clean Defaults || has problems. Nullish coalescing (??) is better. Only null/undefined triggers default. โŒ Logical OR (||) const count = 0; const result = count || 10; // result = 10 (but should be 0!) โœ… Nullish Coalescing (??) const count = 0; const result = count ?? 10; // […]

Read More
HTML

HTML: Use Datalist for Auto-Complete Input

- 11.07.26 - ErcanOPAK comment on HTML: Use Datalist for Auto-Complete Input

๐Ÿ“‹ Datalist = Auto-Complete Input Typing suggestions improve UX. Datalist adds auto-complete. Search, select, suggestions. ๐Ÿ“ Datalist Basics <!– Simple datalist –> <label for=”browser”>Choose a browser:</label> <input list=”browsers” id=”browser” name=”browser” placeholder=”Type to search…” > <datalist id=”browsers”> <option value=”Chrome”> <option value=”Firefox”> <option value=”Safari”> <option value=”Edge”> <option value=”Opera”> </datalist> <!– Country selection –> <input list=”countries” id=”country” placeholder=”Search […]

Read More
CSS

CSS: Master Position Property for Layout Control

- 11.07.26 - ErcanOPAK comment on CSS: Master Position Property for Layout Control

๐Ÿ“ Position = Layout Control Elements need precise positioning. Position property controls layout. Static, relative, absolute, fixed, sticky. ๐Ÿ“ Position Types /* Static (default) */ position: static; – Normal flow – No positioning /* Relative */ position: relative; – Relative to normal position – Offset with top, right, bottom, left – Other elements not affected […]

Read More
Windows

Windows 11: Use Windows Terminal for Modern CLI

- 11.07.26 - ErcanOPAK comment on Windows 11: Use Windows Terminal for Modern CLI

๐Ÿ–ฅ๏ธ Windows Terminal = Modern CLI CMD is old. Windows Terminal is modern. Multiple shells, tabs, themes โ€” powerful CLI. ๐Ÿ“ Windows Terminal Features # Install Windows Terminal – Microsoft Store: Windows Terminal – GitHub: releases – Winget: winget install Microsoft.WindowsTerminal # Key Features – Multiple tabs – Split panes – GPU acceleration – Custom […]

Read More
AI

AI Prompt: Generate Competitive Analysis Report

- 11.07.26 - ErcanOPAK comment on AI Prompt: Generate Competitive Analysis Report

๐Ÿ“Š AI Competitive Analysis Know your competition. AI generates competitive reports โ€” strengths, weaknesses, opportunities. ๐Ÿ“ The Prompt Generate a competitive analysis report for: Company: [Your company] Industry: [Your industry] Product: [Your product] Competitors: [Competitor 1, 2, 3] Provide: 1. Competitor Overview – Company info – Key products – Target market 2. SWOT Analysis – […]

Read More
Docker

Docker: Master Container Lifecycle Management

- 11.07.26 - ErcanOPAK comment on Docker: Master Container Lifecycle Management

๐Ÿ”„ Container Lifecycle = Control Containers need management. Lifecycle commands control everything. Run, stop, restart, remove. ๐Ÿ“ Lifecycle Commands # Create container (without running) docker create –name myapp nginx:latest # Run container (create + start) docker run –name myapp nginx:latest docker run -d –name myapp nginx:latest # Detached # Start/Stop container docker start myapp docker […]

Read More
Kubernetes

Kubernetes: Understand Service Discovery (DNS)

- 11.07.26 - ErcanOPAK comment on Kubernetes: Understand Service Discovery (DNS)

๐ŸŒ Service Discovery = DNS Services need to find each other. Service Discovery uses DNS. Automatic, built-in, easy. ๐Ÿ“ DNS Basics # Service DNS format service-name.namespace.svc.cluster.local # Example my-service.default.svc.cluster.local # Short form (same namespace) my-service # With port my-service.default.svc.cluster.local:8080 # Headless Service (No cluster IP) apiVersion: v1 kind: Service metadata: name: headless-service spec: clusterIP: None […]

Read More
Wordpress

WordPress: Master Hooks (Actions & Filters)

- 11.07.26 - ErcanOPAK comment on WordPress: Master Hooks (Actions & Filters)

๐Ÿ”Œ Hooks = WordPress Power Need to modify WordPress? Hooks are the way. Actions and filters โ€” extend anything. ๐Ÿ“ Actions vs Filters # Actions (Do something) // Add action add_action(‘init’, ‘my_init_function’); function my_init_function() { // Run on init echo ‘Initializing…’; } // Remove action remove_action(‘init’, ‘my_init_function’); # Filters (Modify something) // Add filter add_filter(‘the_content’, […]

Read More
Photoshop

Photoshop: Master Raw Editing with Camera Raw

- 11.07.26 - ErcanOPAK comment on Photoshop: Master Raw Editing with Camera Raw

๐Ÿ“ท Raw Editing = Maximum Quality JPEG is limited. Raw editing unlocks full potential. More data, more control, better results. ๐Ÿ“ Camera Raw Basics # Open Camera Raw – File โ†’ Open (select raw file) – Or: Filter โ†’ Camera Raw Filter # Basic Adjustments – Temperature: White balance – Tint: Color correction – Exposure: […]

Read More
Visual Studio

Visual Studio: Use Bookmarks for Code Navigation

- 11.07.26 - ErcanOPAK comment on Visual Studio: Use Bookmarks for Code Navigation

๐Ÿ”– Bookmarks = Code Navigation Finding code is time-consuming. Bookmarks mark important lines. Jump instantly, navigate faster. โŒจ๏ธ Bookmark Shortcuts Ctrl + K, Ctrl + K โ†’ Toggle bookmark Ctrl + K, Ctrl + N โ†’ Next bookmark Ctrl + K, Ctrl + P โ†’ Previous bookmark Ctrl + K, Ctrl + L โ†’ Clear […]

Read More
C#

C#: Use Task-Based Asynchronous Pattern (TAP)

- 11.07.26 - ErcanOPAK comment on C#: Use Task-Based Asynchronous Pattern (TAP)

โšก TAP = Asynchronous Programming Async is essential. TAP is the standard pattern. Async/await, Task, Task. ๐Ÿ“ TAP Basics // Basic async method public async Task GetDataAsync() { using var client = new HttpClient(); var result = await client.GetStringAsync(“https://api.example.com/data”); return result; } // Async with error handling public async Task GetUserAsync(int id) { try { […]

Read More
C#

C#: Master Exception Handling with Try-Catch

- 11.07.26 - ErcanOPAK comment on C#: Master Exception Handling with Try-Catch

๐Ÿ›ก๏ธ Exception Handling = Robust Code Apps crash without error handling. Try-catch handles errors gracefully. Robust, reliable apps. ๐Ÿ“ Try-Catch Basics try { // Code that might throw int result = int.Parse(input); Console.WriteLine($”Result: {result}”); } catch (FormatException ex) { Console.WriteLine($”Invalid format: {ex.Message}”); } catch (OverflowException ex) { Console.WriteLine($”Number too large: {ex.Message}”); } catch (Exception ex) […]

Read More
SQL

SQL: Use Subqueries for Complex Data

- 11.07.26 - ErcanOPAK comment on SQL: Use Subqueries for Complex Data

๐Ÿ“Š Subqueries = Complex Data Single queries are limited. Subqueries nest queries. Complex conditions, derived data. ๐Ÿ“ Subquery Examples — Users with orders over $100 SELECT name, email FROM users WHERE id IN ( SELECT user_id FROM orders WHERE total > 100 ); — Users with no orders SELECT name, email FROM users WHERE id […]

Read More
Asp.Net Core

.NET Core: Add Globalization for Localization

- 11.07.26 - ErcanOPAK comment on .NET Core: Add Globalization for Localization

๐ŸŒ Globalization = Localization Reach global audience. Globalization adds localization. Multiple languages, cultures, formats. ๐Ÿ“ Setup // Program.cs builder.Services.AddLocalization(options => options.ResourcesPath = “Resources”); builder.Services.AddControllersWithViews() .AddViewLocalization() .AddDataAnnotationsLocalization(); builder.Services.Configure(options => { var supportedCultures = new[] { new CultureInfo(“en-US”), new CultureInfo(“tr-TR”), new CultureInfo(“de-DE”), new CultureInfo(“fr-FR”) }; options.DefaultRequestCulture = new RequestCulture(“en-US”); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); app.UseRequestLocalization(); […]

Read More
Git

Git: Use .gitignore to Exclude Files

- 11.07.26 - ErcanOPAK comment on Git: Use .gitignore to Exclude Files

๐Ÿ“ .gitignore = Exclude Files Commit unwanted files? .gitignore excludes them. Clean repos, no clutter. ๐Ÿ“ .gitignore Examples # .gitignore # Node.js node_modules/ npm-debug.log package-lock.json yarn.lock # .NET bin/ obj/ *.user *.suo *.dll *.pdb # Python __pycache__/ *.py[cod] *.so .Python env/ venv/ # Java *.class *.jar *.war target/ # Environment files.env .env.local .env.production # IDE […]

Read More
Ajax

Ajax: Use Server-Sent Events for Real-Time Feeds

- 11.07.26 - ErcanOPAK comment on Ajax: Use Server-Sent Events for Real-Time Feeds

๐Ÿ“ก Server-Sent Events = Real-Time Feeds Need real-time updates? SSE streams data from server. Live feeds, notifications, dashboards. ๐Ÿ“ SSE Setup // Server (Node.js) app.get(‘/api/events’, (req, res) => { res.setHeader(‘Content-Type’, ‘text/event-stream’); res.setHeader(‘Cache-Control’, ‘no-cache’); res.setHeader(‘Connection’, ‘keep-alive’); let counter = 0; const interval = setInterval(() => { res.write(`data: ${JSON.stringify({ id: counter++, time: new Date().toISOString() })}\n\n`); }, 1000); […]

Read More
JavaScript

JavaScript: Master ES6 Classes for OOP

- 11.07.26 - ErcanOPAK comment on JavaScript: Master ES6 Classes for OOP

๐Ÿ“ฆ ES6 Classes = OOP in JavaScript Prototypes are confusing. ES6 Classes make OOP simple. Constructor, inheritance, methods. ๐Ÿ“ Class Basics // Class declaration class User { constructor(name, email) { this.name = name; this.email = email; this.createdAt = new Date(); } greet() { return `Hello, ${this.name}!`; } getEmail() { return this.email; } } // Usage […]

Read More
HTML

HTML: Draw with Canvas API

- 11.07.26 - ErcanOPAK comment on HTML: Draw with Canvas API

๐ŸŽจ Canvas API = Drawing Power Need to draw graphics? Canvas API creates 2D graphics. Draw, animate, create games. ๐Ÿ“ Canvas Basics <canvas id=”myCanvas” width=”400″ height=”200″></canvas> <script> const canvas = document.getElementById(‘myCanvas’); const ctx = canvas.getContext(‘2d’); // Rectangle ctx.fillStyle = ‘#3498db’; ctx.fillRect(10, 10, 100, 50); // Circle ctx.beginPath(); ctx.arc(200, 75, 40, 0, Math.PI * 2); ctx.fillStyle […]

Read More
CSS

CSS: Master Display Property for Layouts

- 11.07.26 - ErcanOPAK comment on CSS: Master Display Property for Layouts

๐Ÿ“ Display = Layout Control Display controls layout. Block, inline, flex, grid โ€” choose right display for perfect layout. ๐Ÿ“ Display Types /* Block */ display: block; – Full width – Line break before/after – Margin, padding, width, height – Examples: div, p, h1, section /* Inline */ display: inline; – Only as wide as […]

Read More
Windows

Windows 11: Backup and Restore for Data Safety

- 11.07.26 - ErcanOPAK comment on Windows 11: Backup and Restore for Data Safety

๐Ÿ’พ Backup and Restore = Data Safety Data loss is devastating. Backup and Restore protects your files. Back up regularly, restore when needed. ๐Ÿ“ Backup Options # File History – Settings โ†’ Update & Security โ†’ Backup – Add a drive – Automatically back up files # System Image Backup – Control Panel โ†’ Backup […]

Read More
AI

AI Prompt: Generate Professional Project Proposals

- 11.07.26 - ErcanOPAK comment on AI Prompt: Generate Professional Project Proposals

๐Ÿ“„ AI Project Proposals Proposals take time. AI generates proposals โ€” scope, timeline, budget. Win more clients. ๐Ÿ“ The Prompt Generate a project proposal for: Project Name: [Your project] Client: [Client name] Industry: [Your industry] Scope: [What’s included] Budget: [Estimated budget] Timeline: [Expected duration] Provide: 1. Executive Summary 2. Project Overview – Background – Problem […]

Read More
Docker

Docker: Master Port Mapping for Services

- 11.07.26 - ErcanOPAK comment on Docker: Master Port Mapping for Services

๐Ÿ”Œ Port Mapping = Expose Services Containers need external access. Port mapping exposes services. Map container ports to host. ๐Ÿ“ Port Mapping Basics # Basic port mapping docker run -p 8080:80 nginx # Host port 8080 โ†’ Container port 80 # Multiple ports docker run -p 8080:80 -p 5432:5432 postgres # UDP ports docker run […]

Read More
Kubernetes

Kubernetes: Use Pod Lifecycle Hooks

- 11.07.26 - ErcanOPAK comment on Kubernetes: Use Pod Lifecycle Hooks

๐Ÿ”„ Pod Lifecycle Hooks Pods have lifecycle events. Lifecycle hooks run at specific times. Init, pre-stop, post-start. ๐Ÿ“ Hook Types apiVersion: v1 kind: Pod metadata: name: app spec: containers: – name: app image: myapp:latest lifecycle: postStart: exec: command: [“/bin/sh”, “-c”, “echo ‘Container started'”] preStop: exec: command: [“/bin/sh”, “-c”, “echo ‘Container stopping’ && sleep 5”] # […]

Read More
Wordpress

WordPress: Optimize Performance with Caching

- 11.07.26 - ErcanOPAK comment on WordPress: Optimize Performance with Caching

โšก Caching = WordPress Speed Slow sites lose visitors. Caching speeds up WordPress. Page cache, object cache, CDN. ๐Ÿ“ Caching Types # 1. Page Caching – Save HTML output – Serve static files – WP Rocket, W3 Total Cache # 2. Object Caching – Cache database queries – Redis, Memcached – Faster database access # […]

Read More
Page 1 of 2
1 2 Next ยป

Posts pagination

1 2 Next »
July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (597)
  • Add Constraint to SQL Table to ensure email contains @ (582)
  • Average of all values in a column that are not zero in SQL (545)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (512)
  • Find numbers with more than two decimal places in SQL (460)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (857)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com