+ 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 Respuestas
+ 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?