Category:C#

  • Understand how c# generics work

    Time:2021-8-2

    preface We all know the importance of generics in c#. Generics are the most important embodiment of polymorphism of the three major features in OOP language. Almost generics support the whole. Net framework. Before talking about generics, we can throw a problem. Now we need an array class with expandable capacity, which can meet all […]

  • Unity custom editor interface (inspector interface)

    Time:2021-8-2

    In the process of development, you often need to add some buttons in the component to perform some custom operations. For example, you have a component A with a list < collider >, in which you want to store all collider data in the current scene. Then you will write a method find in component […]

  • How to use const, readonly, static in C #

    Time:2021-8-1

    Const, readonly and static keywords are often used in development. It is certain that these keywords are completely different concepts, but sometimes they are so similar in usage that they do not know which to choose in the scene. In this article, we will discuss const, static and readonly keywords in c# and compare them […]

  • Analysis of value transfer between WinForm forms

    Time:2021-8-1

    Source code   https://github.com/SHAREVIEW/winform_ valnue-from-form-2-form_ 20190919.git There are many ways to transfer values between WinForms. Here I use delegate and event to transfer values Create a new windows application and create two WinForms. In fact, they are two classes Add a button and a textbox to each WinForm Write agents and events in winform2 as […]

  • How to write a cleaner controller in asp.net core

    Time:2021-7-31

    You can follow some best practices to write a cleaner controller. Generally, we call the controller written in this method thin controller. The advantage of thin controller is that it has less code, more single responsibility, easy to read and maintain, and it is easy to make multiple versions of controller as time goes by. […]

  • C# custom attribute get interface implementation example code

    Time:2021-7-31

    General interface implementation polymorphism Define interface interface Ipeople { void say(); } Define implemented classes public class man : Ipeople { public void say() { MessageBox.Show(“man”); } } public class woman : Ipeople { public void say() { MessageBox.Show(“woman”); } } General implementation method Upgrade Add custom (there are many online) Implementation class Call method […]

  • Use of mock framework MOQ

    Time:2021-7-30

    Use of mock framework MOQ Intro MOQ is a very popular mock framework in. Net. Using the mock framework, we can only test the code we are concerned about, and use the mock object to configure the expected behavior of dependent services for dependencies. MOQ is based onCastleBased on the dynamic agent technology, the types […]

  • C # realizes the process of converting each page of PPT into pictures

    Time:2021-7-30

    To convert PPT to picture, you first need to reference two DLLs. I use this version here Microsoft.Office.Interop.PowerPoint 12.0 Microsoft Office 12.0 object Library As shown below: The code is as follows: private void pptToImg(string pptPath, string imgPath) { var app = new Microsoft.Office.Interop.PowerPoint.Application(); var ppt = app.Presentations.Open(pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse); var index = 0; […]

  • How to use channels in c#

    Time:2021-7-29

    In the faceProducer consumerIn this scenario, NETCORE provides a new namespaceSystem.Threading.ChannelsTo help us deal with such problems more efficiently. With this channel,producerandconsumerThey can handle their own tasks without interfering with each other, which is conducive to the concurrent processing of both parties. In this article, we will discuss how to use themSystem.Threading.Channels。 Dataflow vs Channel […]

  • Explain string splicing in C # @$

    Time:2021-7-29

    I:@ @It means the character marked with @ in which all symbols are string symbols. There are no special characters, such as’ ‘, which are string by default static void Main(string[] args) { //In this way, it is convenient to write and read the file path, and there is no need for any escape characters […]

  • How to use Lamar in ASP. Net core

    Time:2021-7-28

    ASP. Net comes with a minimalist coreOut of the boxIn fact, you can also use third-party dependency injection containersDependency injection containerInstead of it, dependency injection is a design pattern that can effectively decouple objects and improve unit testing and maintainability. You can use itDependency injectionTo improve your code design, instead of new objects everywhere. Lamar […]

  • Implementation method of c# request uniqueness verification supporting high concurrency

    Time:2021-7-28

    Usage scenario description: The sending request is often encountered in the network request. The server response is successful, but a network failure occurs when returning, resulting in the client unable to receive the request result. Then the client program may judge as a network failure and send the same request repeatedly. Of course, if the […]