我想在THIS答案解釋,總結一本字典的所有值(字符串,布爾值),但我得到的錯誤:錯誤試圖總結字典的價值
Overload resolution failed because no accessible 'Sum' accepts this number of type arguments
我也tryed對.netFiddle與此:
Imports System.Linq
imports system.collections.generic
Public Module Module1
Public Sub Main()
Dim a as integer
Dim Dic As new dictionary(of string, boolean) _
from {{"First", 0},{"Second",0},{"Third",1}}
a = Dic.values.Sum()
End Sub
End Module
並得到相同的錯誤。 我錯過了什麼?
編輯: 我知道,如果我改變dictionary(of string, boolean)
爲dictionary(of string, integer)
,但我想知道如果我可以使用sum()
檢查布爾值或不代碼將工作。
你想在這裏總結什麼?關鍵是一個字符串,其值是一個布爾值。你想知道有多少值是真的? – Steve
@Steve是的。然後我將所有的值放入一個字符串(「001」) – genespos
@varocarbas我只希望問題的答案 - 我發現的答案!請參閱 – genespos