Class Cs.DelegateDeclaration

java.lang.Object
org.openrewrite.csharp.tree.Cs.DelegateDeclaration
All Implemented Interfaces:
Cs, org.openrewrite.java.tree.J, org.openrewrite.java.tree.Statement, org.openrewrite.Tree
Enclosing interface:
Cs

public static final class Cs.DelegateDeclaration extends Object implements Cs, org.openrewrite.java.tree.Statement
Represents a C# delegate declaration which defines a type that can reference methods. Delegates act as type-safe function pointers and provide the foundation for events in C#.

For example:

 // Simple non-generic delegate with single parameter
 public delegate void Logger(string message);

 // Generic delegate
 public delegate T Factory() where T : class, new();

 // Delegate with multiple parameters and constraint
 public delegate TResult Convert<T, TResult>(T input)
     where T : struct
     where TResult : class;

 // Static delegate (C# 11+)
 public static delegate int StaticHandler(string msg);

 // Protected access
 protected delegate bool Validator(T item);