Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > BOOK: Beginning Visual C# 2010
|
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2011, 10:51 PM
Authorized User
 
Join Date: Nov 2011
Posts: 34
Thanks: 14
Thanked 0 Times in 0 Posts
Default Chapter 11 Deep copy Card Class,page 301

public class Card : CollectionBase,ICloneable
{

public object clone()
{
Card newcard = new Card();
foreach (Card sourcecard in List)
{
newcard.addcard(sourcecard.clone() as Card);
}

return newcard;


}


public readonly Suit suit;
public readonly Rank rank;
public void addcard(Card newcard)
{
List.Add(newcard);
}
public void removecard(Card oldcard)
{
List.Remove(oldcard);
}
public Card()
{
}





public Card this[int cardindex]
{
get
{
return (Card)List[cardindex];
}
set
{
List[cardindex] = value;

}



}


public void copyto(Card targetcard)
{
for (int index = 0; index < this.Count; index++)
{
targetcard[index] = this[index];
}
}
public bool contains(Card card)
{
return InnerList.Contains(card);
}



public Card(Suit newsuit, Rank newrank)
{
suit = newsuit;
rank = newrank;
}




}
}




Ch10CardLib.cs.Cards does not implement interface member 'System.ICloneable.Clone()
 
Old November 19th, 2011, 03:59 PM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

Quote:
Originally Posted by dampyr View Post

Ch10CardLib.cs.Cards does not implement interface member 'System.ICloneable.Clone()
This means that the type Cards does not implement the Clone method defined by the interface ICloneable. Verify for correct case.
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel
The Following User Says Thank You to ChristianNagel For This Useful Post:
dampyr (November 20th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 11 Deep Clone,page 301 dampyr BOOK: Beginning Visual C# 2010 1 November 19th, 2011 04:02 PM
Chapter 9 - Page 301 Try it Out demac3 BOOK: Beginning ASP.NET 4 : in C# and VB 7 December 9th, 2010 02:47 PM
CH 12 page 301 (overloaded method) jon4554 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 1 March 2nd, 2010 03:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.