#post
.NET 6 is on the way, and I wanted to share some of my favorite new APIs in .NET and ASP.NET Core that you are going to love. Why are you going to love them? Well because they were directly driven by our fantastic .NET developer community! Let’s get started!
Read more...
.NET 6 is on the way, and I wanted to share some of my favorite new APIs in .NET and ASP.NET Core that you are going to love. Why are you going to love them? Well because they were directly driven by our fantastic .NET developer community! Let’s get started!
Read more...
#post
For .NET 6, we have made FileStream much faster and more reliable, thanks to an almost entire re-write. For same cases, the async implementation is now a few times faster!
Read more...
For .NET 6, we have made FileStream much faster and more reliable, thanks to an almost entire re-write. For same cases, the async implementation is now a few times faster!
Read more...
#post
In this post, I'd like to have a look into minimal APIs.
With the preview 4, Microsoft simplified the simplest project template to an absolute minimum. Microsoft created this template to make it easier for new developers to start creating small microservices and HTTP APIs.
Read more...
In this post, I'd like to have a look into minimal APIs.
With the preview 4, Microsoft simplified the simplest project template to an absolute minimum. Microsoft created this template to make it easier for new developers to start creating small microservices and HTTP APIs.
Read more...
#post
Now, for the final post in this mini-series, let's turn our attention to a feature that was originally scheduled for release in C# 10, but didn't quite make the cut: required properties.
Read more...
Now, for the final post in this mini-series, let's turn our attention to a feature that was originally scheduled for release in C# 10, but didn't quite make the cut: required properties.
Read more...
📝 What is the difference between continue and break statements in C#?
🔸 using break statement, you can jump out of a loop
🔸 using continue statement, you can jump over one iteration and then resume your loop execution
#post
🔸 using break statement, you can jump out of a loop
🔸 using continue statement, you can jump over one iteration and then resume your loop execution
#post
📝 When to use Finalize vs Dispose?
🔸 The finalizer method is called when your object is garbage collected and you have no guarantee when this will happen (you can force it, but it will hurt performance).
🔸 The Dispose method, on the other hand, is meant to be called by the code that created your class so that you can clean up and release any resources you have acquired (unmanaged data, database connections, file handles, etc) the moment the code is done with your object.
The standard practice is to implement
And in your finalizer, you call
#post
🔸 The finalizer method is called when your object is garbage collected and you have no guarantee when this will happen (you can force it, but it will hurt performance).
🔸 The Dispose method, on the other hand, is meant to be called by the code that created your class so that you can clean up and release any resources you have acquired (unmanaged data, database connections, file handles, etc) the moment the code is done with your object.
The standard practice is to implement
IDisposable
and Dispose
so that you can use your object in a using
statement such as using(var foo = new MyObject()) { }
.And in your finalizer, you call
Dispose
, just in case the calling code forgot to dispose of you.#post
📝 What are Property Accessors?
The get and set portions or blocks of a property are called accessors.
These are useful to restrict the accessibility of a property.
🔸 The set accessor specifies that we can assign a value to a private field in a property and without the set accessor property it is like a read-only field.
🔸 By the get accessor we can access the value of the private field. A Get accessor specifies that we can access the value of a field publicly.
#post
The get and set portions or blocks of a property are called accessors.
These are useful to restrict the accessibility of a property.
🔸 The set accessor specifies that we can assign a value to a private field in a property and without the set accessor property it is like a read-only field.
🔸 By the get accessor we can access the value of the private field. A Get accessor specifies that we can access the value of a field publicly.
#post
📝 You have defined a destructor but it never executed. Why?
The runtime environment automatically invokes the destructor of a class to release the resources that are occupied by variables and methods of an object.
However, in C#, programmers cannot control the timing for invoking destructors, as Garbage Collector is only responsible for releasing the resources used by an object.
Garbage Collector automatically gets information about unreferenced objects from .NET's runtime environment and then invokes the
Although, it is not preferable to force Garbage Collector to perform garbage collection and retrieve all inaccessible memory (programmers can use the
Take notice that the destructor doesn't (and can't) have a public modifier in-front of it, it's sort of an hint that you can't explicitly call the destructor of an object.
#post
The runtime environment automatically invokes the destructor of a class to release the resources that are occupied by variables and methods of an object.
However, in C#, programmers cannot control the timing for invoking destructors, as Garbage Collector is only responsible for releasing the resources used by an object.
Garbage Collector automatically gets information about unreferenced objects from .NET's runtime environment and then invokes the
Finalize()
method.Although, it is not preferable to force Garbage Collector to perform garbage collection and retrieve all inaccessible memory (programmers can use the
Collect()
method of the Garbage Collector class to forcefully execute Garbage Collector).Take notice that the destructor doesn't (and can't) have a public modifier in-front of it, it's sort of an hint that you can't explicitly call the destructor of an object.
#post