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.
The Mikado Method by Ola Ellnestam Daniel Brolund(25294)
Hello! Python by Anthony Briggs(24339)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(23434)
Kotlin in Action by Dmitry Jemerov(22512)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(21976)
Dependency Injection in .NET by Mark Seemann(21849)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(20715)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(19524)
Grails in Action by Glen Smith Peter Ledbrook(18610)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17034)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(11857)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(8097)
Microservices with Go by Alexander Shuiskov(7869)
Practical Design Patterns for Java Developers by Miroslav Wengner(7782)
Test Automation Engineering Handbook by Manikandan Sambamurthy(7744)
Angular Projects - Third Edition by Aristeidis Bampakos(7227)
The Art of Crafting User Stories by The Art of Crafting User Stories(6678)
NetSuite for Consultants - Second Edition by Peter Ries(6598)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(6361)