Category: C#

  • C# LINQ methods and their JavaScript equivalents

    Here’s a breakdown of common C# LINQ methods and their JavaScript equivalents, including Sum and Avg: Filtering (Where): Both methods filter the collection based on a condition. The condition is specified in an arrow function in JavaScript. Finding First Match (Find): Both methods return the first element that matches the condition. If no match is…

  • How to use Visual Studio IEnumerable Debugger Visualizer

    Imagine you’re debugging your code in Visual Studio, and you come across a variable holding a bunch of data, like a list of customers or a shopping cart full of items. Normally, inspecting this data can be a pain. You might have to squint at a long line of text or click through endless menus.…

  • Using C# Record Types

    I find Zoran Horvat’s videos easy to follow and understand. Here is a new short video he published about C# Record Types. A Record is a regular class with two public read-only properties. Besides construction, no mutation on the object Console.WriteLine nicely prints a record object. Linq distinct works well with the list of records…

  • int.Parse() and Convert.ToInt32() and int.TryParse()

    int.Parse() and Convert.ToInt32() If we send null: int.TryParse() – a better one https://www.c-sharpcorner.com/article/safest-way-to-convert-string-to-int-in-c-sharp/ #csharp #dotnet #backtobasics

  • .NET Core Worker Service with EF Core

    In ASP.NET Core applications, the services can be scoped, that can be resolved or instantiated at the start of a request, and disposed of at the end of a request. But in Worker Service type of applications, the definition of scope is not clear. That’s why we need to implement scoping ourselves. Let’s say every…

  • Linode Object Storage with .NET and C#

    Linode Object Storage is now available on Frankfurt data centre [1]. It is much more affordable and easier to manage unstructured data such as content assets (images, files etc..), sophisticated and data-intensive storage challenges around artificial intelligence and machine learning. Since it is S3-compatible object storage, we can use AWS SDK for .NET for any…

  • Deserialize json array with System.Text.Json

    Json Data And the class and method for deserialization A post about the performance of system.text.json #json #System.Text.Json #net-core #dotnet

  • JSON Type with MySQL & EF Core

    Since MySQL 5.7.8, you can leverage the built-in json data type to store flexible, semi-structured data in your database. This approach offers several benefits over traditional relational models, especially when dealing with complex or frequently changing data. Let’s explore how to effectively work with JSON data in MySQL using Entity Framework Core (EF Core). Storing…

  • Configuration in .NET Core

    Configuration in .NET Core https://tahirnaushad.com/2017/08/15/asp-net-core-configuration/ and oficial page: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration #dotnet #net-core

  • .NET Core and .NET Standard

    A nice article from MSDN Magazine: .NET Standard – Demystifying .NET Core and .NET Standard And a great video series about .NET Standard from the same author: https://www.youtube.com/playlist?list=PLRAdsfhKI4OWx321A_pr-7HhRNk7wOLLY #net-standard #net-core #resources #dotnet

  • Inheritance Simply

    Basics are important. Involving in big projects may make us underestimate and forget about the basics. While I was rechecking the important feature of OOP: inheritance, I wanted to share very simple example briefly. My little piece of code here calculates the surface and volume of a rectangular prism and calculates its cost based on its volume.…

  • Simple XML Reading,Writing and Serialization

    Altough JSON became more common, XML is still an important markup language. As a snippet, I created an example project which will be creating a Books.xml file and reading it from the file. First of all, let’s create a class called Book with parameters of book name, writer and list of readers.

  • Basics of LINQ

    Some notes on LINQ Language-Integrated Query (LINQ) is the technology that provides tools for developers to use query directly in the programming language (C#). A query is an expression that retrieves data from a data source. In LINQ, you work with objects. You use the codes to query and transform data in XML documents, SQL databases, Datasets, collections, and…

  • Thread was being aborted, Response.Redirect

    Sometimes, trying to handle exceptions with a statement that redirects the page, we may get a ThreadAbortException error. “If you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs. You can use a try-catch statement to catch this exception.” The solution is using these two lines: Response.Redirect(url,false); Context.ApplicationInstance.CompleteRequest(); Oficilal solution page from Microsoft:…

  • Check if string contains only digits

    Fastest way to check if string contains only digits https://stackoverflow.com/questions/7461080/fastest-way-to-check-if-string-contains-only-digits Difference between Char.IsDigit() and Char.IsNumber() in C#

  • Remove the last character of a StringBuilder object

    Updating data depending on the whether or not the parameters are set may cause various problems. For example, In this case, if you send only ID to set, as it will be the last parameter in the query, it may cause an  error. By removing last comma, you can add as many parameters as you…