TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Don Ireland
NA
27
7.2k
add object to List. Msg "No constructor accepts 3 args
Apr 5 2014 8:04 PM
I have a List<T> object that is a collection of custom objects and when I attempt to add my custom object to the list, it it tells me "myOject does not contain a constructor that takes 3 arguments". But the thing is that myObject has only one constructor and it DOES take 3 args.
Here's the definition for myObject.
class myObject
{
#region variables
private Int64 _id;
private Int64 _origID;
private String _name;
#endregion
#region properties
public Int64 id
{
get { return this._id; }
}
public Int64 origID
{
get { return this._origID; }
}
public String name
{
get { return this._name; }
}
#endregion
#region methods
public void myObject(Int64 id, Int64 origID, String name) // <-- Constructor
{
this._id = id;
this._origID = origID;
this._name = name;
}
#endregion
}
And here's the attempt to add it to the list:
List<myObject> obj = new List<myObject>();
for (i=0,i<cat.Count,i++){
obj.Add(new myObj(i, cat.id, cat.name)); //<-- This line throws an error at compile time as noted above
}
Reply
Answers (
1
)
Array
Changing the size of the characters