Beginner's Guide to C# Programming: A Practical Approach in Visual Studio by Serhan Yamacli
Author:Serhan Yamacli [Yamacli, Serhan]
Language: eng
Format: epub
Published: 2017-07-02T07:00:00+00:00
Let’s use an if statement in an example where the user will enter a
username and a password. Our program will check if they are valid:
1. Create a C# project.
2. Add three Labels, two TextBoxes and one Button on the form as in
Figure 8.17.
3. Set the Text of the first Label as Login window.
4. Set the Texts of the second and third Labels as Username: and
Password:.
223
BEGINNER’S GUIDE TO C# PROGRAMMING
Figure 8.17. Layout of the form
5. Set the Name properties of TextBoxes as usernameTextBox and
passwordTextBox, respectively.
6. Set the Name and Text of the Button as Login and loginButton.
7. Double-click the Button to create its Click event handler method as
usual. We will use the if statement inside this method. We don’t have
a database yet therefore let’s compare the username and password
against constant values such as csharpprogrammer and abc456,
respectively. We do this in the if statement as follows:
if (usernameTextBox.Text == "csharpprogrammer" &&
passwordTextBox.Text == "abc456")
{
MessageBox.Show("Login successful");
}
Code 8.15
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12578)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8302)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7697)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7096)
Microservices with Go by Alexander Shuiskov(6864)
Practical Design Patterns for Java Developers by Miroslav Wengner(6780)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6722)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Angular Projects - Third Edition by Aristeidis Bampakos(6135)
The Art of Crafting User Stories by The Art of Crafting User Stories(5656)
NetSuite for Consultants - Second Edition by Peter Ries(5590)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5400)
Kotlin in Action by Dmitry Jemerov(5066)
