Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Taking input from the User | Introduction
Introduction to .NET with C#
course content

Зміст курсу

Introduction to .NET with C#

Introduction to .NET with C#

1. Introduction
2. Asynchronous Programming and Introduction to Web Services
3. Introduction to Databases with .NET
4. CRUD Operations with MySQL
5. Optimizing Database Operations

bookTaking input from the User

Recap:

  • Console.ReadLine() statement can be used for taking input from the user, in the form of a string;

  • Every built-in data type has a Parse method. It can be used for extracting data of that type from a string;

  • Giving a value of a very big magnitude (can be positive or negative) for int.Parse will crash the program. This happens because int has a limited capacity, and if the number is bigger than that capacity, the program doesn't know what to do, so it crashes. In cases where values of big magnitude are expected, using long.Parse is preferable;

  • Using float.Parse when dealing with very precise values can potentially cause loss of data because float has a limited precision, and parsing a very precise value will cause the program to round off the input - therefore causing some loss of precision/data. It is preferable to use double.Parse in such cases;

  • A character can be parsed from a string using the char.Parse() method. It can also be parsed via indexing as well. So using Console.ReadLine()[0] is a shorter way of writing char.Parse(Console.ReadLine()).

1. Which method is used for taking input from the user?
2. What is the type of returned data from the <code>Console.ReadLine()</code> method?
3. What will be the output of the following statement?
4. Assuming that the user enters an empty string as an input, what will be the output of the following statement?
Which method is used for taking input from the user?

Which method is used for taking input from the user?

Виберіть правильну відповідь

What is the type of returned data from the <code>Console.ReadLine()</code> method?

What is the type of returned data from the Console.ReadLine() method?

Виберіть правильну відповідь

What will be the output of the following statement?

What will be the output of the following statement?

Виберіть правильну відповідь

Assuming that the user enters an empty string as an input, what will be the output of the following statement?

Assuming that the user enters an empty string as an input, what will be the output of the following statement?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3
We're sorry to hear that something went wrong. What happened?
some-alt