Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm a beginner at programming C#. I have a task which asks to create a program and input a symbol which needs to be printed, max number of symbols printed in one line and how many symbols you could print based on choice(for example like from 0-100 i input in console 54 and it prints out 54 symbols).

What I have tried:

Have tried looking on the internet for examples on how to input a certain amount of characters.
Posted
Updated 6-Sep-18 3:25am
v2

1 solution

To input, you probably need to use Console.ReadLine:
C#
string input = Console.ReadLine();
You can then convert the second input to a number using TryParse:
C#
int count;
string countAsString = Console.ReadLine();
if (!int.TryParse(countAsString, out count))
   {
   Console.WriteLine("\"{0}\" is not a number!", countAsString);
   }
else
   {
   // count now contains the number the user entered.
   ... process your count and symbols here ...
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900