我有一个interger数组列表,想要删除其中一个。 [英] I have a list of interger arrays and want to remove one of them.
问题描述
我有下面的代码,并将整数数组添加到整数数组列表中。当我尝试从列表中删除项目时,我收到以下错误:
严重性代码说明项目文件行抑制状态
错误CS1503参数1:无法从'int'转换为'int []'EdgeTelemetryProvider C:\ToolChainRR \ EdgeTelemetryProvider \ MainForm.cs 255 Active
静态列表< int []> filterForMsgsCopy = new List< int []>();
public MainForm()
{
InitializeComponent();
int [] filter = new int [2];
filter [0 ] = 0x0001;
过滤器[1] = 0x88;
filterForMsgs.Add(过滤器);
int [] filter1 = new int [2];
filter1 [0] = 0xbeef;
filter1 [1] = 0x89;
filterForMsgs.Add(filter1);
int [] filter2 = new int [2];
filter2 [0] = 0xbabe;
filter2 [1] = 0xB8;
filterForMsgs.Add(filter2);
filterForMsgs.Remove(1);
我尝试过:
我在互联网上看到了没有找到解决这个问题的任何东西。我之前使用过列表,删除字符串,整数等列表没有问题,但在尝试删除整数数组列表时遇到问题。
如果1是你要删除的项目的索引(即0是第一个,1是第二个,依此类推)然后使用RemoveAt
filterForMsgs .RemoveAt(1);
I have the code below and am adding an integer array to a list of integer arrays. When I try and remove an item from the list I get the following error:
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'int' to 'int[]' EdgeTelemetryProvider C:\ToolChainRR\EdgeTelemetryProvider\MainForm.cs 255 Active
static List<int[]> filterForMsgsCopy = new List<int[]>();
public MainForm()
{
InitializeComponent();
int[] filter = new int[2];
filter[0] = 0x0001;
filter[1] = 0x88;
filterForMsgs.Add(filter);
int[] filter1 = new int[2];
filter1[0] = 0xbeef;
filter1[1] = 0x89;
filterForMsgs.Add(filter1);
int[] filter2 = new int[2];
filter2[0] = 0xbabe;
filter2[1] = 0xB8;
filterForMsgs.Add(filter2);
filterForMsgs.Remove(1);
What I have tried:
I have looked on the internet and not found anything to solve this problem. I have used lists before and had no problem removing lists of strings, integers etc. but have a problem when trying to remove a list of integer arrays.
If 1 is the index of the item you want to remove (ie 0 is the first, 1 the second and so on) then use RemoveAt
filterForMsgs.RemoveAt(1);
这篇关于我有一个interger数组列表,想要删除其中一个。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!