4 C# Methods & User Input
This chapter covers
- The console class and its further uses
- All about the convert class methods
- The anatomy and usage of classes
- Definition of methods
- How we can use methods in our algorithms
- Development process of a random number comparator
Nearing the end of Part 1 – Introduction to the C# Programming Language, we slowly become more familiar with the C# development process. We find new types and shapes of coding language with each chapter that we can use to build our programs. Until now, we learned the fundamental basic building blocks. We learned about variables, datatypes, Randomness, operators, and conditionals and got pretty good at working in our development environment.
However, everything we have built only served as programs that gave us a result once after execution, with no way of getting further interaction from it. This limitation will change in this chapter 4, where methods and user input will be the main focus.
This chapter's project will consist of a random number generator that will store that number and wait for the user to try and guess it. Each time a user input number is given, the algorithm will compare it to the random number generated and tell the user if the guessed number is too high, too low, or matched.
Although simple, this will significantly aid us in the understanding of methods in C# and the different ways of receiving runtime data from the user.