generic collection and item

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px
Hello,
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px
This is my 4th question(here is http://social.msdn.microsoft.com/Forums/en-CA/csharpgeneral/thread/a398a224-2a64-4771-9b4d-b512c42d40a9
1 , http://social.msdn.microsoft.com/Forums/en-CA/csharpgeneral/thread/854a9a48-4ac6-48f4-bf17-07ff0b6b1712
2 , and http://social.msdn.microsoft.com/Forums/en-CA/csharpgeneral/thread/0cf1720f-1d87-4914-9f4f-22503d151953
3 ), thanks http://social.msdn.microsoft.com/profile/konrad%20neitzel/?ws=usercard-mini" target="_blank" style="font-family:inherit; font-style:inherit; background-color:#e0f0c0; font-size:15px; line-height:13.999999046325684px; border:none; margin:0px; outline:0px; padding:0px; color:#0066dd; text-decoration:none; list-style-type:none Konrad
Neitzel , http://social.msdn.microsoft.com/profile/reed%20copsey,%20jr/?ws=usercard-mini" target="_blank" style="font-family:inherit; border:none; font-style:inherit; margin:0px; outline:0px; padding:0px; color:#0095c4; text-decoration:none; list-style-type:none; background-color:#e0f0c0; font-size:15px; line-height:14px Reed
Copsey, Jr and <span style="font-family:inherit; border:0px; font-style:inherit; margin:0px 0.5em 0px 0px; outline:0px; padding:0px; list-style-type:none; font-size:14px; line-height:17px; vertical-align:top; color:green http://social.msdn.microsoft.com/profile/christoph%20basedau/?type=forum&referrer=http://social.msdn.microsoft.com/Forums/en-CA/csharpgeneral/thread/a398a224-2a64-4771-9b4d-b512c42d40a9 " title="About Christoph Basedau" style="border:none; font-style:inherit; margin:0px; outline:0px; padding:0px; color:#0095c4; text-decoration:none; list-style-type:none; vertical-align:top; font-size:14px; line-height:17px Christoph
Basedau . now I have a bug in my code:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px

<pre class="prettyprint" style=" public interface ILocData<T> where T: new ()
{
T Copy();
...
}

public class LocDataCollection<T, TCollection> : List<T>
where T : ILocData<T>, new ()
where TCollection : LocDataCollection<T, TCollection>, new ()
{
public TCollection Copy()
{
TCollection locDatas = new TCollection();
foreach (T locData in this)
{
T locData2 = locData.Copy();
locDatas.Add(locData2);
}
return locDatas;
}
...
}[/code]
and
<pre class="prettyprint" style=" public class TypeA : ILocData<TypeA>
{
public TypeACollection Parent;

public TypeA Copy()
{
TypeA dept = new TypeA();
...

dept.Parent = Parent; // *** this is wrong when a instance of TypeACollection.Copy

return dept;
}
}

public class TypeACollection : LocDataCollection<TypeA, TypeACollection>
{
...
}[/code]
My question will be, is it possible, move
public DeptCollection Parent;
to ILocData and change LocDataCollection.Copy to work with it. Is there any solution? Or I have to go some other way?

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13.333333015441895px; line-height:16.66666603088379px


Thank you so much
<
Wes
<br/>

<br/>
<br/>

View the full article
 
Back
Top