+ 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
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);
}
}
}
+ 1
this can probably explain it better than me...
https://stackoverflow.com/questions/31757953/what-does-primary-constructor-body-not-allowed-mean
0
Oh... Thanks! ...But what does primary constructor not allowed mean?