O'Reilly logo

Beginning C# 7 Hands-On – The Core Language by Tom Owsiak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required