Click here to Skip to main content
15,665,166 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 19-Mar-18 14:00pm

1 solution

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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900