Created
June 22, 2016 07:27
-
-
Save Phuseos/655c697050035d56e6a04ff415243631 to your computer and use it in GitHub Desktop.
Expression bodies on method-like members (C#)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Expression bodies on method-like members example ***/ | |
| /**This example shows how voids that only return methods or statements can be build using the 'lambda arrow' | |
| The void below takes a string and returns it as a JavaScript alert window to the user **/ | |
| void CreateMessage(string Message) | |
| { | |
| System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('" + Message + "');", true); | |
| } | |
| //With the new expression body, the void will look like this: | |
| void CreateMessage(string Message) => System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('" + Message + "');", true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment