In this post we will see how we can create PDF documents in C# Windows forms using iText7 library. The final PDF file contains Product details in a table format, seller information and customer information. It is a sample PDF invoice document. You are required to install iText7 library nuget package in your Windows forms application project using the Nuget Package manager option.
我之前的博客中有介绍如何在项目中生成额外的代码，也有介绍制作一个生成代码的 NuGet 包。而本文是在此基础上更进一步，可以让生成代码变成实时的；更准确的说，是在保存文件时即生成代码，而无需完整编译一次项目。一天，头像全白昵称空格的“wuweilai”童鞋问我为什么 GRPC 的 NuGet 包能自动在 .proto 文件保存时更新生成的代码，怎么才能做到像它那样。然后，我研究了下 Grpc.Tools 包里的代码，外加跟他反复讨论，摸清了自动生成代码的方法。
本文来聊聊在重写某个类的 GetHashCode 方法时，可以如何实现 GetHashCode 的返回值。按照 GetHashCode 方法的原则，要求两个对象如果 Equals 返回 true 那么一定要求 GetHashCode 也返回相同的值。当然，反过来不成立，也就是两个对象返回的 GetHashCode 的值相同，对象可以是不相等的。实现 GetHashCode 方法的方式有很多，最简单的就是通过调用基类的 GetHashCode 方法，代码如下...
Since I primarily work on internal business applications, I often find myself writing the same kinds of code multiple times. One of the most common situations is a "status message" or some kind of display to the user that lets them know that something successfully happened, or there's some kind of error, or warning, or just a friendly reminder...
I've got a quick tip this week, about tests and a cool feature of C#. For better or for worse, my team and I often build projects that are large, complex beasts. In all of them, we prefer to use Dependency Injection as a way to construct complex objects.
I wanted to write this post because I realized that a lot of developers have difficulty writing asynchronous delegates. I often see synchronous delegates in code review that could be transformed. So in this post I will show you how to proceede without however going over the usefulness of asynchronism, this is not the purpose of this post.
The C# compilers have been open source since 2014, now in the dotnet/roslyn repository. The dotnet/csharplang split off to provide a dedicate public space for the innovation and evolution of the C# language. Now, dotnet/csharpstandard completes the group, providing a public space for the ongoing work to document the standard for the latest C# language versions.
.NET 5 (released in November 2020) includes support for C# 9, a major new version of the C# programming language. This series of articles explores the new features in .NET’s main programming language. In this first article, we’ll look at top-level statements and target-typed new and conditional expressions. These features make C# less verbose and can be used in everyday programs.
In this article, we continue to explore string manipulations by focusing on interpolation. Instead of concatenating many pieces together, interpolation allows us to insert special tokens inside a string. A value then replaces those tokens. Interpolation and concatenation play the same role, but often one ends up being more elegant than the other and makes the code easier to maintain.
Do you want to start writing unit tests and you don't know how to start? Were you asked to write some unit tests on a past interview? Let's see what is a unit test and how to write your first unit tests in C#.
In this blog post, let’s look at C# 9.0 pattern matching in switch expressions. In the previous blog post you learned about using patterns with the is pattern expression, and you learned about the new relational patterns in C# 9.0, and also about the new pattern combinators and and or. If you haven’t read the previous blog post, I recommend you to read it, as I don’t repeat the basics of relational patterns and pattern combinators in this blog post.