+ 1

C#. What i did wrong?

I want to make a rectangle, my cod is below using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { int lenght = Console.ReadLine(); int wight = Console.ReadLine(); for (a = 0; a < lenght + 1;a++) { for (b = 0; a < wight + 1;b++) { Console.WriteLine (#); } } } } } Errors: cs1040, cs1026, cs1002

23rd Jul 2022, 3:14 PM
Роман Плуталов
5 Answers
+ 1
ReadLine() reads text, the string form. Convert to destination type. int length = int.Parse( Console.ReadLine() ) ; Same for next.. In loop a, b are undeclared. Declare it. for ( int a = 0; Same for b. Console.WriteLine("#") ; enclose text in quotes " " . WriteLine() adds line break. Write() don't adds line break. See deferences. Hope it helps..
23rd Jul 2022, 3:29 PM
Jayakrishna 🇮🇳
+ 1
Big thanks! I haven't programming about 2 months, do i forgot everything.
23rd Jul 2022, 5:14 PM
Роман Плуталов
0
Ugh. Something is wrong again. I fixed everything, and now code works, but it's just "######################## ###############################################". I inserted: 2 and 2
23rd Jul 2022, 5:58 PM
Роман Плуталов
23rd Jul 2022, 6:28 PM
Роман Плуталов
0
Роман Плуталов for (a = 0; a < lenght; a++) { for (b = 0; b < wight; b++) //b < wight, not a < wight.... { Console.Write("#"); } Console.WriteLine(); // adds line break }
24th Jul 2022, 11:35 AM
Jayakrishna 🇮🇳