Using
System;
Using
System. Collections. Generic;
Using
System. LINQ;
Using
System. text; NamespaceFuncdemo{ClassProgram{Static VoidMain (String[] ARGs){//Similar delegation FunctionFuncString,Int>Test=Tsetmothod; Console. writeline
This is a creation in
Article, where the information may have evolved or changed.
Image package implements a basic 2D image library, which contains the basic interface called image, which contains color, which is described in Image/color,
There are
I. [Action <>] specifies the delegates with only input parameters and no return value.
1.1 define a delegate:
For example, the original write delegate:
Public Delegate void mydelegate (string Str); this delegate indicates that it can only delegate
Introduction to C # Delegates (delegate, Action, Func, predicate)A delegate is a class that defines the type of the method so that the method can be passed as a parameter to another method. An event is a special kind of delegate.1. Declaration of
Let's look at an example of a delegate from the previous chapter:1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceTest8 {9 class ProgramTen { One Static
This is a creation in
Article, where the information may have evolved or changed.
A simple Web program was written in the Notebook, but the compilation failed with the hint "syntax error:nested func not allowed".
Do not understand what the
Following the previous EventHandler, continue to pits, and briefly understand the Func delegate and the Action delegate.MSDN's explanation for both:Func: Encapsulates a method that does not have a parameter but returns the type value specified by
Read CatalogueOne: Duplicate code Two: Eliminate duplicate code by delegating func in C #One: Duplicate code1 Public classpersion2 {3 Public stringName {Get;Set; }4 Public intAge {Get;Set; }5 6 Publicpersion
A function is a collection of statements organized together to perform a specific task.Swift functions are similar to simple C functions and complex Objective C language functions. It enables us to call internal local and global parameter values
Atitit JS development tool IDE Code structure display (func list) Outline summaryEclips Environment:: 4.3.1#-------Need a JS development tool that can display the functionality of outline or code structure display (func list)Aptana,webstorm Good ten
Predicate is a delegate that represents a method, which is defined as:namespace System { // Summary: represents a method that defines a set of conditions and determines whether the specified object conforms to those conditions. // parameter:
In the object-oriented design, we often talk about "restructuring". In the reconstruction process, there is a merging method, that is, similar to, or, the method body is very long, so we need to consider them and abstract them!
Original code:
predicate generic delegateRepresents a method that defines a set of conditions and determines whether the specified object conforms to those conditions. This delegate is used by several methods of the Array and list classes to search for elements in
Often see Func This way of writing, see This is no mind to look down. We still need to be quiet when we learn technology.The Func to func goes to the definition to see its explanation: //Summary: //encapsulates a method that has a parameter
Today, I flipped through the GCC manual and found these two documents. One is the nested function, that is, GCC allows a function to be defined inside another function:
Double
Foo (
Double
A,
Double
B)
...
{ Double Square ( Double
Overview:
In addition to defining a new delegate type for each parameter and return type, you can use the action and func delegate.
Action
Action delegate indicates referencing a method of the void return type.
Func
Func delegate allows
Anonymous delegates and lambda expressions that use the action, func,eventhandler,params keyword-decorated parameters
In. NET, we often use the delegate, the role of the delegate needless to say, before. NET 2.0, before we use the delegate, we have
This paper analyzes the use of predicate and func generic Delegate in C # By example, and shares it for everyone's reference. Specific as follows:Let's take a look at the following example:static void Main (string[] args) { list L = new list (); L.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.