C#/LINQ Quereying a class -
i'm using sam jenkin's deck of cards class. i'm trying query cards in suit. i'm getting error:
cannot implicitly convert type 'system.collections.generic.ienumerable' 'system.collections.generic.ienumerable'. explicit conversion exists (are missing cast?)
i've tried moving things around i'm not understanding error. please help? code is:
var deck = new deck(); ienumerable<deck> deckquery = mycard in deck.cards mycard.suit == suit.club select mycard.cardnumber;
my card class is:
public class card : icard { public suit suit { get; set; } public cardnumber cardnumber { get; set; } }
my enumerators are:
public enum suit { club = 1, diamond = 2, heart = 3, spades = 4, } public enum cardnumber { ace = 1, 2 = 2, 3 = 3, 4 = 4, 5 = 5, 6 = 6, 7 = 7, 8 = 8, 9 = 9, ten = 10, jack = 11, queen = 12, king = 13, }
you're selecting cardnumber
, trying place deck:
// won't work: // ienumerable<deck> deckquery = ienumerable<cardnumber> deckquery = mycard in deck.cards mycard.suit == suit.club select mycard.cardnumber;
the other option select card itself:
ienumerable<card> deckquery = mycard in deck.cards mycard.suit == suit.club select mycard;
Comments
Post a Comment