I've been working a week on teaching myself C# (with no C++ or Java), on a project of making an elaborate poker-hand parser. I'm finally caving in and posting my first simple question.
I think I've seen variable declarations in various ways (new to my VB/A experience). Here's the general idea of what I'd like to do.
public class CompareHandsClass : IComparer<clHiHand>
...
public class clCardsHeld
{
protected List<clCard> _liCards = new List<clCard>();
public clCardsHeld(List<clCard> CardsList)
{ _liCards = CardsList;
}
...
public class clHiHand : clCardsHeld
{
public clHiHand(List<clCard> CardsList) : bas开发者_运维知识库e(CardsList) {}
List<clCard> _liTempCards;
CompareHandsClass HandComparer = new CompareHandsClass();
...
if (_liTempCards.Count >= 5
&& HandComparer.Compare(clHiHand x = new clHiHand(_liTempCards),
clHiHand y = new clHiHand(_liFlushCards)))
So my problem is down at the end with HandComparer.Compare. I've got two Lists of my clCard type, but I can't send them to .Compare() because that takes clHiHand objects. So I'm trying to send the lists as arguments to constructors of temporary clHiHand type variables all at once. I can do this somehow can't I (aside from using several lines of declarations)? Thanks for any beginner's help (I'm kind of disappointed I get stumped on this little thing of all places...)
Oh and, PS, I hope I didn't mess up anything else in this sample code, since I've gotten away from my last working version with these extensions.
You can lose the clHiHand x
and clHiHand y
. The call then looks like
HandComparer.Compare(new clHiHand(_liTempCards), new clHiHand(_liFlushCards))
精彩评论