+ 1

What’s wrong in this code?

So I was making a code(C#) Just to make sure I understand what I’m reading, and it says something like “Primary constructor not allowed”(?) I’m not sure what it is, and I don’t know how to fix it, so someone please tell me. https://code.sololearn.com/c3u1PluZORiG/?ref=app

30th Oct 2019, 7:21 PM
Jake
3 Answers
+ 1
hi Jake this issue with your code is a “;” at the end of the definition for the SayHi() method. here’s the corrected code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { class Person { public int Age; public string Name; public void SayHi() { Console.WriteLine("Hello!"); } } static void Main(string[] args) { Person p1 = new Person(); p1.Age = 23; p1.Name = "Jake"; p1.SayHi(); Console.WriteLine(p1.Age); } } }
30th Oct 2019, 7:24 PM
Ollie Q
Ollie Q - avatar
30th Oct 2019, 7:34 PM
Ollie Q
Ollie Q - avatar
0
Oh... Thanks! ...But what does primary constructor not allowed mean?
30th Oct 2019, 7:30 PM
Jake