Displaying the results

Now, imagine that there are entries in both the boxes. In that case, you need to display some text. So, for example, type the following code:

Label1.Text = "Your entries have been saved";

Here, you're pretending that you're saving to a database. In real life, that's not so easy; you've got to write a lot more code. On the other hand, if one of the boxes is empty or both the boxes are empty, you have to display a relevant message. So, first you will say else, and then within a set of curly braces, you will say the following:

else{    Label1.Text = "Both entries must be specified.";}

Remember to close this with a semicolon. That's it. This is our simple program!

Now, let's add a couple of comments in simple English, starting ...

Get Beginning C# 7 Hands-On – The Core Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.