Reputation: 3
First off, I'm sorry for asking such a simple question in such a sophisticated place. I'm writing a one-off app to parse a text file. It's a console app with the typical static Main().
I've declared another class like so. I've omitted the get/set because of the nature of the operation (it will be used once...never again).
public class Entry
{
public List<string> numbers;
public string rm;
public string time;
public string desc;
Entry(List<string> n, string r, string t, string d)
{
numbers = n;
rm = r;
time = t;
desc = d;
}
}
When I try to instantiate the class in Main() with this statement:
Entry newEntry = new Entry(numbers, rn, time, desc);
I receive the error that Entry doesn't have a constructor that takes 4 arguments. All of the variables being passed match the constructor definition types. I'm sleep-deprived and confused. What am I doing wrong?
Thanks, and sorry for the stupid question.
Upvotes: 0
Views: 194
Reputation: 425033
Try making the constructor public
:
public Entry(List<string> n, string r, string t, string d)
Upvotes: 2
Reputation: 14956
You have made the constructor private. If you don't use an access modifier for your constructor, it will be set as private by default. Put "public" in front of the constructor and it should work:
public class Entry
{
public List<string> numbers;
public string rm;
public string time;
public string desc;
public Entry(List<string> n, string r, string t, string d)
{
numbers = n;
rm = r;
time = t;
desc = d;
}
}
Upvotes: 4