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
Jim Feng
NA
29
0
Declare a new object instance from an exist object instance
Oct 25 2017 12:10 PM
I try to code a common method to fill in an class object list with datatable as following:
public static List FillDataTable(object obj, DataTable dt)
{
List objList = new List();
object o = new object(); //how to declare this instance based on the object obj???
foreach (DataRow dr in dt.Rows)
{
//code to fill datarow to the object o
objList.Add(o);
}
return objList;
}
Call this method as followiing:
List lstObj = new List();
lstObj = FillDataTable(((object)new myClass()), dt).OfType().ToList();
Reply
Answers (
2
)
OLEDB Connection
How to edit data in search result in c#