[ad_1]
カードゲームを C# に変換しています
非常に頻繁に表示される1つのケースでは、エラーが発生します
エラー CS1061 ‘ItemCollection’ には ‘Item’ の定義が含まれておらず、タイプ ‘ItemCollection’ の最初の引数を取るアクセス可能なアイテム拡張メソッドが見つかりませんでした (使用ディレクティブまたはアセンブリ参照が欠落している可能性があります)。
エラー CS1061 “ItemCollection” には “Item” の定義が含まれておらず、”ItemCollection” 型の初期引数を受け入れるアクセス可能な項目拡張メソッドが見つかりませんでした (using ディレクティブまたはアセンブリ参照が欠落している可能性があります)。
「withBlock.Item(n)」で問題が発生
VB:
<Extension()> Public Function SelectFirstCardCommonCheck_ALL(hc As HandCards, Wnd As MainWindow, ByVal CardsPanel As Object, TrumpID As Integer, LeadSuitID As Integer) As PlayingCard Dim sHand As String Dim FindCard As PlayingCard Dim ACP As New AutoCardPlay(Wnd.sk.trumpCard, Wnd) sHand = hc.GetHandString With CardsPanel.Items sHand = String.Empty If .Count > 0 Then For n = 0 To .Count - 1 If Wnd.iTricks > 5 Then If NonTrumpCards(hc, TrumpID) IsNot Nothing Then If NonTrumpCards(hc, TrumpID).Contains(GetEichelHighestPlayableCard(Wnd.TrickHistory)) Then If .Item(n).ToString = GetEichelHighestPlayableCard(Wnd.TrickHistory) Then FindCard = .Item(n) End If If NonTrumpCards(hc, TrumpID).Contains(GetLaubHighestPlayableCard(Wnd.TrickHistory)) Then If .Item(n).ToString = GetLaubHighestPlayableCard(Wnd.TrickHistory) Then FindCard = .Item(n) End If If NonTrumpCards(hc, TrumpID).Contains(GetSchellHighestPlayableCard(Wnd.TrickHistory)) Then If .Item(n).ToString = GetSchellHighestPlayableCard(Wnd.TrickHistory) Then FindCard = .Item(n) End If Else If hc.GetHighestCard(LeadSuitID, TrumpID) IsNot Nothing Then If .Item(n).ToString = hc.GetHighestCard(LeadSuitID, TrumpID).ToString Then FindCard = CardsPanel.Items.Item(n) End If End If End If If FindCard Is Nothing Then Dim curCard As PlayingCard = ACP.SelectBestFirstCard(CardsPanel, hc.PlayerID, Wnd.sk.declarer, Wnd.GameStatus, sHand, TrumpID, hc, Wnd, LeadSuitID) If curCard IsNot Nothing AndAlso curCard.CardType <> TrumpID Then FindCard = curCard If FindCard.CardValue = 2 Or FindCard.CardValue = 3 Then Wnd.sk.leadSuit = TrumpID If FindCard.CardValue = 2 Or FindCard.CardValue = 3 Then LeadSuitID = TrumpID End If End If Else If FindCard Is Nothing Then Dim curCard As PlayingCard = ACP.SelectBestFirstCard(CardsPanel, hc.PlayerID, Wnd.sk.declarer, Wnd.GameStatus, sHand, TrumpID, hc, Wnd, LeadSuitID) If curCard IsNot Nothing AndAlso curCard.CardType <> TrumpID Then FindCard = curCard 'If FindCard IsNot Nothing Then Debug.Print("ALL 77 FindCard: " & FindCard.ToString) If FindCard.CardValue = 2 Or FindCard.CardValue = 3 Then Wnd.sk.leadSuit = TrumpID If FindCard.CardValue = 2 Or FindCard.CardValue = 3 Then LeadSuitID = TrumpID End If End If End If Next End If End With If FindCard IsNot Nothing Then Return FindCard End Function
私が試したこと:
public static PlayingCard SelectFirstCardCommonCheck_ALL(this HandCards hc, MainWindow Wnd, ListBox CardsPanel, int TrumpID, int LeadSuitID) { string sHand; var FindCard = default(PlayingCard); var ACP = new AutoCardPlay(Wnd.sk.trumpCard, Wnd); sHand = hc.GetHandString(); { var withBlock = CardsPanel.Items; sHand = string.Empty; if (Conversions.ToBoolean(Operators.ConditionalCompareObjectGreater(withBlock.Count, 0, false))) { for (int n = 0, loopTo = Conversions.ToInteger(Operators.SubtractObject(withBlock.Count, 1)); n <= loopTo; n++) { if (Wnd.iTricks > 5) { if (NonTrumpCards(hc, TrumpID) is not null) { if (NonTrumpCards(hc, TrumpID).Contains(Extensions_TrickMonitoring.GetEichelHighestPlayableCard(Wnd.TrickHistory))) { if ((withBlock.Item(n).ToString() ?? "") == (Extensions_TrickMonitoring.GetEichelHighestPlayableCard(Wnd.TrickHistory) ?? "")) FindCard = (PlayingCard)withBlock.Item(n); } if (NonTrumpCards(hc, TrumpID).Contains(Extensions_TrickMonitoring.GetLaubHighestPlayableCard(Wnd.TrickHistory))) { if ((withBlock.Item(n).ToString() ?? "") == (Extensions_TrickMonitoring.GetLaubHighestPlayableCard(Wnd.TrickHistory) ?? "")) FindCard = (PlayingCard)withBlock.Item(n); } if (NonTrumpCards(hc, TrumpID).Contains(Extensions_TrickMonitoring.GetSchellHighestPlayableCard(Wnd.TrickHistory))) { if ((withBlock.Item(n).ToString() ?? "") == (Extensions_TrickMonitoring.GetSchellHighestPlayableCard(Wnd.TrickHistory) ?? "")) FindCard = (PlayingCard)withBlock.Item(n); } } else if (hc.GetHighestCard(LeadSuitID, TrumpID) is not null) { if ((withBlock.Item(n).ToString() ?? "") == (hc.GetHighestCard(LeadSuitID, TrumpID).ToString() ?? "")) { FindCard = (PlayingCard)CardsPanel.Items.Item(n); } } if (FindCard is null) { var curCard = ACP.SelectBestFirstCard(CardsPanel, hc.PlayerID, Wnd.sk.declarer, Wnd.GameStatus, sHand, TrumpID, hc, Wnd, LeadSuitID); if (curCard is not null && (int)curCard.CardType != TrumpID) { FindCard = curCard; if ((int)FindCard.CardValue == 2 | (int)FindCard.CardValue == 3) Wnd.sk.leadSuit = TrumpID; if ((int)FindCard.CardValue == 2 | (int)FindCard.CardValue == 3) LeadSuitID = TrumpID; } } } else if (FindCard is null) { var curCard = ACP.SelectBestFirstCard(CardsPanel, hc.PlayerID, Wnd.sk.declarer, Wnd.GameStatus, sHand, TrumpID, hc, Wnd, LeadSuitID); if (curCard is not null && (int)curCard.CardType != TrumpID) { FindCard = curCard; // If FindCard IsNot Nothing Then Debug.Print("ALL 77 FindCard: " & FindCard.ToString) if ((int)FindCard.CardValue == 2 | (int)FindCard.CardValue == 3) Wnd.sk.leadSuit = TrumpID; if ((int)FindCard.CardValue == 2 | (int)FindCard.CardValue == 3) LeadSuitID = TrumpID; } } } } } if (FindCard is not null) return FindCard; return default; }
解決策 2
引用:C#withBlock.Item(n)
Item
通常、インデクサー プロパティの名前です。 試す:
C#
withBlock[n]
ItemCollection.Item[Int32] プロパティ (System.Windows.Controls) | マイクロソフト ラーン[^]
解決策 1
[ad_2]
コメント