In C#, a NullReferenceException occurs when we try to access a variable whose value has not been set or has been set to null. It can be easy to trigger this exception accidentally, so it’s important to be aware of how to avoid it in the first place. In this article, we’ll take a look at some common causes of NullReferenceException errors and how to fix them. We’ll also discuss ways to prevent NullReferenceException errors from happening in the first place.
.NET provides a handy way to deal with monitoring different file system changes. In this article, we will discuss what FileSystemWatcher is, how to set it up, and how to configure it to observe various file system changes. In addition, we will take a look at the caveats of FileSystemWatcher.
朋友们大家好，我是Rector，码友网的创建者和维护者，专注C#&.NET技术开发。本文为大家分享的主题是《C# 11新特性之原始字符串》，本文相应的视频: C# 11新特性-原始字符串美国时间2022年4月18日，微软发布了Visual Studio 17.2 预览版 3和.NET 7预览版 3，其中包含了一些C# 11的新特性，本视频就为大家演示一下C# 11中的原始字符串这个新特性。微软官方的表述是:” Raw string literals”，这里翻译成”原始字符串”。从字面不难看出，它是适用于字符串的新特性，解决字符串中特殊字符的新语法。原始字符串字面量可以包含任意文本，包括空格、新...
In this article, we are going to deal with a special case of JSON processing, polymorphic serialization, and deserialization with System.Text.Json. The introduction of the System.Text.Json package has given .NET developers another powerful option for JSON format handling. You can get a full description of the package here.
In this article, we’re going to learn how to serialize a C# object into a JSON string using the two main JSON libraries in the .NET ecosystem. Also, we’re going to learn how to control different aspects of the serialization process.
In this article, we are going to learn more about ranges and indices in C#, and how to use them to access a single or a range of elements in a sequence. We’ll also see how ranges and indices help us write cleaner and more readable code.
Performance is always an important factor in software development. It is not something only the developers of a framework must consider. When the .NET team released the Span<> class they empowered developers to improve application performance, if used correctly. In this article, we will learn about Span in C#, how it is implemented, and how we can use it to increase performance.
Winfrom各种老毛病真的不适合做大型项目，甚至中型项目都不适合，一些小功能都能把你折腾半死，比如，我想在界面上显示一个进度条，用来显示现在硬盘和内存已经使用了多少，使用了 ProgressBar 控件你看看效果：进度条中间一直有个白色光影在晃来晃去的，是不是想让别人感慨：“哇！好强的光芒，我的眼睛快睁不开了...”。而且背景颜色无法改变，这个动画也无法关掉，为了解决这两个问题，我找了很久，终于找到了下面的解决方法。二、自定义进度条于是我在网上找了一些资料，有到效果有，但不是特别漂亮，比如下面这个C# WinForm 自定义进度条控件_科技_品阅网另外，我参考了下面到帖子Win...
In this second part of my series on IAsyncEnumerable
In this article, we will learn the different methods to remove duplicates from a list in C#. List
In this article, we are going to learn how to call a generic method in C# using reflection. Generic methods are an all-time favorite of library developers for their inherent reusability and type inference benefits. But because of the need for explicit type arguments in most cases (except when type inference occurs implicitly), we can’t always make the best use of them in compile time. This is where reflection comes into play.
In this post I'll talk about the process of using the Roslyn C# Code compilation APIS and the why's and how's of creating a WestWind.Scripting wrapper and more importantly how I actually use it in one of my popular applications.