Optimize - Một số cách tối ưu code và performance CSharp
Nguồn: viblo.asia
Mở đầu
Cách kiểm tra null
var product = GetProduct();
if (product == null)
{
// Do something if the object is null.
} var product = GetProduct();
if (product is not null)
{
// Do something if the object is not null.
}Tối ưu code với if- else
Sử dụng using
Tối ưu cách đọc một Logical Expression
Xóa if-else khi check bool values
Với switch case thì sao
Cách tối hơn khi filter exception
Tóm lại
Last updated