🕌 Modern, User-Friendly Prayer Times Application Completely free, portable prayer times application for Windows — no installation required. Supports 203 countries and 4,120+ cities worldwide. ✨ Features 🌍 Global Support: 203 countries, 4,120+ cities worldwide 🇹🇷 🇬🇧 Bilingual: Turkish and English interface đź“– Islamic Library: 28 surahs, 36 prayers, 40 hadiths (favorites & smart search) […]
Category: C#
Namaz Vakitleri Uygulaması v1.1.1
🕌 Modern, Kullanıcı Dostu Namaz Vakitleri Uygulaması Windows için tamamen ĂĽcretsiz, kurulum gerektirmeyen (portable) namaz vakitleri uygulaması. DĂĽnya genelinde 203 ĂĽlke ve 4,120+ Ĺźehri destekliyor. ✨ Ă–zellikler 🌍 KĂĽresel Destek: 203 ĂĽlke, 4,120+ Ĺźehir, TĂĽrkiye’nin tĂĽm il ve ilçeleri 🇹🇷 🇬🇧 Çift Dil: TĂĽrkçe ve İngilizce arayĂĽz đź“– İslami KĂĽtĂĽphane: 28 sure, 36 dua, 40 […]
C# — List.ForEach() Is Slower Than foreach
It allocates a delegate and blocks break/continue. âś… Prefer foreach (var item in list) { }
C# — DateTimeKind.Unspecified Breaks Serialization
Unspecified kind leads to wrong conversions. âś… Rule Always specify: DateTime.SpecifyKind(date, DateTimeKind.Utc)
C# — record Types Can Accidentally Leak Data
record auto-generates ToString(). public record User(string Email, string Password); ❌ Risk Sensitive data may appear in logs. ✅ Fix Override ToString() or avoid records for secrets.
Background Tasks the Right Way
The Problem: You are firing off Task.Run() in a controller and hoping it finishes, but the server kills it. The Fix: Implement BackgroundService. It’s the reliable, built-in way to run long-running processes. public class Worker : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { // Your logic here await Task.Delay(1000, stoppingToken); […]
Hot Reload Configuration with IOptionsSnapshot
The Problem: You changed a value in appsettings.json, but the app keeps using the old value until you restart the server. The Fix: Inject IOptionsSnapshot<T> instead of IOptions<T>. It reads the config file every time the request is made. public class MyService { private readonly MySettings _settings; // Updates immediately when json changes! public MyService(IOptionsSnapshot<MySettings> […]
Splitting Lists with .Chunk()
The Problem: You need to process a list of 10,000 items in batches of 100, but writing the for loop math is tedious and error-prone. The Fix: Since .NET 6, you can simply use LINQ’s .Chunk(). var heavyItems = GetHugeList(); // Instantly splits into arrays of 100 items foreach (var batch in heavyItems.Chunk(100)) { ProcessBatch(batch); […]
Stop Allocating Memory with Span
The Problem: You need to parse a large string (like a substring), but String.Substring() creates a new string object in memory every time, hurting performance. The Fix: Use Span<T>. It provides a type-safe, memory-safe representation of a contiguous region of arbitrary memory without allocation. string text = “2023-10-25”; // Instead of text.Substring(0, 4) which allocates… […]
The Null Coalescing Assignment Operator (??=)
The Problem: You are writing verbose if (variable == null) checks just to assign a default value. The Fix: Use ??= to assign a variable only if it is currently null. It makes your initialization logic incredibly clean. // Old way if (myList == null) { myList = new List<string>(); } // Life-saver way myList […]
C# — using Blocks Can Hide IO Bottlenecks
using var stream = File.OpenRead(path); đź§ Problem Dispose can block while flushing buffers. âś… Rule Avoid heavy IO inside tight loops.
C# — string.Concat Is Faster Than string.Format
Formatting is expensive. âś… Faster var s = string.Concat(a, “-“, b); ❌ Slower string.Format(“{0}-{1}”, a, b); Impact: hot paths, logging, serialization.
C# — readonly Fields Don’t Make Objects Immutable
Many devs assume readonly = immutable. ❌ Reality readonly protects the reference, not the object. readonly List<int> items = new(); items.Add(1); // allowed ✅ Fix Use immutable collections when needed.
Observability — Logs Without Correlation IDs Are Noise
Distributed tracing without IDs is guesswork. âś… Fix Propagate correlation IDs across services.
JSON — Schema Validation Prevents Silent API Breakage
Clients change. APIs break quietly. âś… Fix Validate JSON against schema before processing.
Cancellation — Passing Token Is Not Enough
You passed CancellationToken…but didn’t observe it. ✅ Rule Check ThrowIfCancellationRequested() in loops.
Async Streams — IAsyncEnumerable Saves Memory
Instead of loading everything: await foreach (var item in stream) Benefits Lower memory usage Faster first response Ideal for large datasets
EF Core — Change Tracking Is a Hidden Performance Tax
Tracking thousands of entities slows everything. âś… Fix context.ChangeTracker.QueryTrackingBehavior = NoTracking; Or per query: .AsNoTracking()
Unicode — String Length Is Not What You Think
“👨‍👩‍👧‍👦”.Length // NOT 1 Why UTF-16 code units Grapheme clusters âś… Fix Use text element enumeration for user-visible length.
Time Zones — DateTime.Now Is a Data Corruption Bug
DateTime.Now depends on server locale. ❌ What breaks Distributed systems Daylight Saving Time Audits & reporting ✅ Rule Store UTC, display local. DateTime.UtcNow
.NET Core — Request Aborted Token Is Ignored Too Often
Client disconnects — server keeps working. ✅ Fix Use: HttpContext.RequestAborted Cancel long-running operations immediately.
.NET Core — Async Controllers Can Still Block Threads
Async does NOT guarantee non-blocking. ❌ Hidden blocker Task.Result Task.Wait() ✅ Rule Async all the way — no sync-over-async.
C# — Exceptions Are Extremely Expensive
Exceptions are not control flow. ❌ Bad try { Parse(); } catch { } ✅ Better Use TryParse patterns. Impact Exceptions allocate Capture stack traces Kill throughput under load
C# — foreach Copies Structs Silently
Iterating structs can create hidden copies. foreach (var item in largeStructList) { item.Modify(); // modifies a copy } âś… Fix Use ref foreach: foreach (ref var item in CollectionsMarshal.AsSpan(list))
C# — Memory Works with Async, Span Does Not
Span<T> is stack-only.Once you await, the stack frame is gone. ❌ This breaks Span<byte> buffer = stackalloc byte[256]; await DoAsync(buffer); // 💥 ✅ Correct Memory<byte> buffer = new byte[256]; await DoAsync(buffer); Rule: Span<T> → sync, hot paths Memory<T> → async-safe
C# — Async State Machines Increase Memory Usage
Every async method allocates a state machine. đź§ Impact High-throughput services suffer Hot paths amplify cost âś… Optimization Use sync methods when no awaits are needed.
C# — ConcurrentDictionary Is Not Always Faster
Many devs replace Dictionary blindly. ❌ Reality Slower for low contention Higher memory usage Locks still exist internally ✅ Rule Use ConcurrentDictionary only under real concurrency.
C# — Why readonly struct Can Be Slower Than class
readonly struct looks like a performance win. ❌ Hidden cost Defensive copies are created when passed by value Happens silently in method calls ✅ Fix Pass by in: void Process(in MyStruct value)
.NET Core — Response Compression Isn’t Enabled by Default
Many APIs forget this. builder.Services.AddResponseCompression(); app.UseResponseCompression(); Result Smaller payloads Faster mobile clients Lower bandwidth costs
.NET Core — MapGroup() for API Versioning Without Pain
var v1 = app.MapGroup(“/api/v1”); v1.MapGet(“/users”, GetUsers); Benefits Cleaner routing Shared filters & auth Scales beautifully


