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
ora cle
NA
2
1.1k
c# generic type on where constraint
Apr 8 2017 1:02 PM
Dear All.
I have below simple object model where Manager class consist List Of Child objects and Child object must have reference to it's parent object:
public
class
ManagerBase<T1> where T1 : ChildBase<???>
{
public
ManagerBase()
{
ChildObjects =
new
List<T1>();
}
public
List<T1> ChildObjects {
get
;
set
; }
}
public
class
ChildBase<T1> where T1 : ManagerBase<???>
{
public
ChildBase(T1 parentMgr)
{
ParentMgr = parentMgr;
ParentMgr.ChildObjects.Add(
this
);
}
public
T1 ParentMgr {
get
;
set
; }
}
Above are BASE classes. Now, below are inherited sample Manager and Child classes. I don't know how to make below classes to compile as above BASE classes are not valid yet. Could you pls help? Thanks.
public
class
CatalogManager : ManagerBase<Catalog>
{
}
public
class
Catalog : ChildBase<CatalogManager>
{
}
To provide more clear idea: I have BASE Manager class, BASE Child Object class. There are different type of inherited Managers (CatalogManager, DocumentManager etc.) and different type of Child Objects (Catalog, Document etc). Now, each Manager must consist of List of different type of child object not List of ChildBase. F.e: CatalogManager with List, DocumentManager with List. At the same time, each child object must have reference to it's Manager. In other words, I need strong typing instead of using Base classes. Hope it clear.
Thanks for your time.
Reply
Answers (
1
)
HOW TO CREATE THAT FORMATE IN CRYSTAL REPORT VB.NET WINDOWS
how to create sqldatasource for dropdownlist into gridview