C# Tips

C# Tip Article

Using ref, out param in Lambda

When using Lambda expression, we generally use parameters without specifying their types. For example,


button1.Click += (sender, e) => { /* ... */ }

However, if at least one parameter is ref or out parameter, we cannot use the expression as above. Instead, we have to define all data types for all parameters as below.


ie.DocumentComplete += (object pDisp, ref object url)
                        => { /* ... */ }