I have problems to convert the following piece of code into vb.net because I am not so experienced with lambda expressions. Especially the last line is my problem. Teleric Code Converter doesn't help me because of the last line. Could somebody help me?
int[] numbers = { 1, 3, 4, 9, 2, 4 };
int numToRemove = 4;
int numIndex = Array.IndexOf(numbers, numToRemove);
numbers = numbers.Where((val, idx) => idx != numIndex).ToArray();
Not used VB since VB6(!) - this works though:
Dim numbers() = {1, 3, 4, 9, 2, 4}
Dim numToRemove As Integer = 4
Dim numIndex As Integer = Array.IndexOf(numbers, numToRemove)
numbers = numbers.Where(Function(ByVal val, ByVal idx) idx <> numIndex).ToArray()
(That's just a disclaimer as the above might not be best practices etc!)
Conversion with Telerik works if you store the output of the last line in a new variable. Then you get this:
Private numbers As Integer() = {1, 3, 4, 9, 2, 4}
Private numToRemove As Integer = 4
Private numIndex As Integer = Array.IndexOf(numbers, numToRemove)
Private result = numbers.Where(Function(val, idx) idx <> numIndex)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.