Ever got confused about which one to use in your .NET app? You’re not alone! Let me break it down in simple words. 🧵


📌 IOptions - The Simple One

Think of it as: A sticky note you write once and never change

What it does: Loads your settings when the app starts, and that’s it!

Example:

public class NotificationSettings
{
public string SmtpServer { get; set; }
public int Port { get; set; }
public string DefaultSender { get; set; }
}

public class NotificationService
{
private readonly NotificationSettings _settings;

public NotificationService(IOptions<NotificationSettings> options)
{
_settings = options.Value;
}
}

Use it for: Stuff that never changes - like your SMTP server, database URL, or default sender email The catch: You change the …

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help