3 code examples of using delegates in C#
Updated: March 31, 2015 08:53:51 Submission: junjie
This article mainly introduces three code examples of using delegation in C#. This article directly gives code examples, without any relevant explanations. Friends who need it can refer to it.
using System; namespace DelegateDemo { class Program { private delegate int Cacu(string str); static void Main(string[] args) { //1 Cacu cacu = new Cacu(CacuInstance); (cacu("Hello,Wrold")); //2 Cacu cacu1 = new Cacu(delegate(string str) { return ; }); (cacu1("Hello,Wrold")); //3 Cacu cacu2 = new Cacu((str) => { return ; }); (cacu2("Hello,Wrold")); } static int CacuInstance(string str) { return ; } } }
Related Articles
C# method to connect to encrypted Sqlite database
There are two types of data encryption: one is to encrypt the database itself, and the other is to encrypt the data in the data table. The following article will introduce to you the method of connecting to the encrypted Sqlite database in C#. Interested friends can take a look.2017-08-08Methods to implement picturebox adaptive picture size in WinForm
This article mainly introduces the method of implementing picturebox adaptive picture size in WinForm, involving the skills of setting properties related to pictureBox controls. Friends who need it can refer to it2017-05-05Sharing tips for C# dictionary to specify type
This article mainly introduces the skills of transferring C# dictionary to specified types. The article introduces the code examples in detail, which is of some help to your study or work. Friends in need can refer to it.2023-10-10Detailed explanation of the interface design of models and their in C# API
This article mainly introduces relevant materials about the design of models and their interfaces in C# API. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it, please learn with the editor below.2018-06-06How to use C#.Net ArrayList
This article mainly introduces the usage method of C#.Net ArrayList. The advantage of using dynamic arrays is that it can effectively utilize storage space according to user needs. Friends who need it can refer to it.2015-10-10Detailed explanation of C# serial communication program example
Create a C# serial communication program under the .NET platform. .NET 2.0 provides the function of serial communication. Its namespace is, what is the specific implementation of creating a C# serial communication program? Let's get started2013-12-12C# rewrite DataGridView
This article mainly introduces the relevant information about rewriting DataGridView in C#. Interested friends can refer to it.2016-05-05Method of edge detection (Sobel) for C# image processing
This article mainly introduces the method of edge detection (Sobel) in C# image processing. Use a custom sobel operator function to realize the detection function of image edges. Friends who need it can refer to it.2015-04-04How to attach dependency attributes in c# wpf
This article mainly introduces how C# wpf attaches dependency attributes to help everyone better understand and learn how to use C#. Interested friends can learn about it.2021-03-03C# Summary of defining and using custom event methods in a program
In this article, the editor has compiled relevant knowledge points for you about defining and using custom event methods in C# in programs. Friends who need it will learn it.2019-03-03