Muhammad Waseem Profile picture
May 13 8 tweets 4 min read Twitter logo Read on Twitter
What is the difference b/w field and property , what are the different types of properties in C# ?

- Properties
- Field vs Properties
- 6 Types of Properties

#dotnet Image
Properties vs Field

- Properties are first class citizens in C#
- We used properties to achieve abstraction
- Properties are implemented via accessors
- Enable developers to write code that accurately expresses their design intent
#dotnet Image
Read only Properties

- Serve the purpose of getters
- Use them for retrieving the information in DTO
- We can not set them

#dotnet Image
Write only Properties
- Serve the purpose of setters
- We can not use them for reading the data
#dotnet Image
Auto Implemented Properties
- Use them as setter/getter
- Most simple form of properties

#dotnet Image
Required properties
- Used for validation purpose 
- To make sure that required properties are present

#dotnet Image
Init only Properties
- Used to set the data
- One can set data only during object initialization
- Helpful in creating read-only properties

#dotnet
If you like it , you might be interested in my weekly .NET Newsletter.
Join with 2500+ here : lnkd.in/dNHxJGRG

#dotnet

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Muhammad Waseem

Muhammad Waseem Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mwaseemzakir

Apr 29
💡𝐃𝐨𝐧’𝐭 𝐑𝐞𝐩𝐞𝐚𝐭 𝐘𝐨𝐮𝐫𝐬𝐞𝐥𝐟 (𝐃𝐑𝐘) 𝐏𝐫𝐢𝐧𝐜𝐢𝐩𝐥𝐞

It states that don’t repeat yourself what it means it is saying don’t duplicate code , avoid duplication. Purpose is to reduce the redundant code in your application 🧵⏬
#dotnet Image
Following the DRY Principle can give us following benefits

1.  Improved maintainability of code

2.  Reduces the risks of bugs

3.  Code becomes easier to understand

#dotnet
If you are not applying DRY Principle you need to test/debug all process separately for similar code.

We can fulfil DRY Principle using Inheritance and Polymorphism.

#dotnet
Read 5 tweets
Apr 17
💡 NULL Operators Guide in C#

- Ternary Operator (? :)

- Null Forgiving Operator (!.)

- Null Conditional Operator (?.)

- Null Coalescing Operator (??)

- Null Coalescing Assignment Operator (??=) 🧵⏬

#dotnet Image
Ternary Operator or Conditional Operator(?.)  is used to evaluate a condition and then we can do something on that basis for true and false

#dotnet
Null Forgiving or Null Suppression Operator (!.)  is used to suppress all nullable warnings for preceding expression. It has no effect on runtime

#dotnet
Read 7 tweets
Apr 16
💡HTTP Client Class in C#

. Introduction
Methods
Properties
Dependency injection 🧵⏬

#dotnet Image
HttpClient is a class in C# that is used for making HTTP calls of different kinds (most commonly Get/Put/Delete/Post).This class comes from namespace System.Net.Http
Most commonly used methods of this class are
- GetAsync
- DeleteAsync
- PostAsync
- PutAsync
- Dispose

#dotnet
Read 5 tweets
Apr 9
💡 15+ .NET Libraries you should Know

Now a days libraries play an important role in your development, start learning these libraries for a good development experience.

- Mediator for CQRS
- Dapper for micro-ORM

See more🧵⏬
#dotnet Image
- Serilog and NLog for logging

- Bogus for fake data generation

- Fluent Validation for validations

- SignalR for real time communication

- Moq for mock interfaces and classes

- Hangfire and Quartz for background jobs

- Noda Time best in the town for date-time

#dotnet
- Autofac for Dependency Injection Container

- MiniProfiler for profiling your application

- Automapper, Mapster and Mapperley for Mappings

- Polly for fault handling (Retry, Circuit Break)

#dotnet
Read 5 tweets
Mar 22
💡IEnumerable vs IQueryAble in .NET

1) Whatis IEnumerable
2) What is IQueryAble
3) Difference b/w them ⏬

#csharp #dotnet
IEnumerable and IQueryable interfaces are both used to work with collections of data and both support LINQ (Language Integrated Query)
#dotnet
𝐈𝐐𝐮𝐞𝐫𝐲𝐚𝐛𝐥𝐞

✅ IQueryable executes queries on the server side.

✅ It is designed specifically to work with LINQ

✅ It extends IEnumerable, which means it includes all of the functionality of IEnumerable.
#dotnet
Read 7 tweets
Mar 21
💡Tracking vs Non Tracking Queries in .NET
1) Tracking Queries
2) Non Tracking Queries
3) Identity Resolution
4) How to set tracking by default for context🧵🔽
#dotnet
𝐓𝐫𝐚𝐜𝐤𝐢𝐧𝐠 : By default all queries are tracked , so behind the seen a change tracker keeps working on each entity. If you want to perform Update/Delete then you should use tracking.
#dotnet
𝐍𝐨𝐧 𝐓𝐫𝐚𝐜𝐤𝐢𝐧𝐠 : If you just need read only data then you don't need your queries to keep tracking of change , you can simply go with no tracking and help the query run more speedy.
#dotnet
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(