我需要知道如何將數組或圖像列表傳遞給C#中的另一個類(無所謂哪一個)。我可以創建數組或列表就好,它有我的圖片,但無論我嘗試通過哪一個我得到錯誤「方法的類型參數」'AppLayer.SymbolSetSetup.AddSymbolSet(string,System.Collections.Generic .List)'「不能從usage.thread明確指定類型參數。」傳遞數組或圖像列表C#
我得到這兩個錯誤,當我運行它「錯誤CS1502:最好的重載方法匹配'AppLayer.SymbolSetSetup.AddSymbolSet(字符串,System.Collections.Generic.List)'有一些無效的參數」和「錯誤CS1503 :參數2:不能從'System.Collections.Generic.List'轉換爲'System.Collections.Generic.List'「
不知道它是否重要,但它從WPF項目傳遞到C#類項目。
private void saveDeckButton_Click(object sender, RoutedEventArgs e)
{
AppLayer.SymbolSetSetup ss = new AppLayer.SymbolSetSetup();
// get all images in image dock
int count = imageWrapPanel1.Children.Count;
Image[] imArray = new Image[count];
List<Image> list = new List<Image>();
for (int i = 0; i < count; i++)
{
// get image from button
Button source = (Button)imageWrapPanel1.Children[i];
Image content = source.Content as Image;
imArray[i] = content;
list.Add(content);
}
ss.AddSymbolSet(symbolSetNameTextBox.Text, list);
}
public class SymbolSetSetup : ServerStartup
{
public void AddSymbolSet(string symbolSetName, List<Image> list)
{...
無法看到此類錯誤可能來自的行 - 也許您可以告訴我們編譯器在哪一行中抱怨(如果您還沒有從錯誤中丟棄方法名稱,這會有所幫助) – Carsten 2012-03-26 08:04:17
您能否請您複製並粘貼完整的確切錯誤消息和堆棧跟蹤? – 2012-03-26 08:11:13
對不起,我添加了運行時得到的錯誤。 – Coomikaze 2012-03-26 08:14:46