- Aug
- 2,870
- 153
Now that I can create a plugin in C++/CLI for use with TCC,
I was hoping that I could use LINQ expressions in a plugin.
Here's my test C# Code;
Works as expected;
However, as the subject of this post states,
C++/CLI doesn't support lambda expressions
When attempting to make this a function in a TCC plugin,
VS 2022 kept giving me all of these errors,
and after a Bing search,
I learned that C++/CLI doesn't support lambda expressions.
LINQ in C++/CLI doesn’t have a direct namespace you can import like using namespace System::Linq; the way it does in C#.
LINQ functions are instead part of System::Linq::Enumerable,
meaning you have to reference Enumerable explicitly when using them.
Which led to more errors,
and jumping through hoops.
Posting for my future reference, but others may also be interested.
Joe
I was hoping that I could use LINQ expressions in a plugin.
Here's my test C# Code;
Code:
using System;
using System.Linq;
class Program
{
static void Main()
{
string input = "24 +13+12 +21 +46 +14+10+20+14+ 30 +18+ 50";
var sortedNumbers = input
.Split('+')
.Select(int.Parse)
.OrderBy(n => n)
.ToArray();
Console.WriteLine(string.Join("+", sortedNumbers));
}
}
Works as expected;
Code:
10+12+13+14+14+18+20+21+24+30+46+50
However, as the subject of this post states,
C++/CLI doesn't support lambda expressions
When attempting to make this a function in a TCC plugin,
VS 2022 kept giving me all of these errors,
and after a Bing search,
I learned that C++/CLI doesn't support lambda expressions.
LINQ in C++/CLI doesn’t have a direct namespace you can import like using namespace System::Linq; the way it does in C#.
LINQ functions are instead part of System::Linq::Enumerable,
meaning you have to reference Enumerable explicitly when using them.
Which led to more errors,
and jumping through hoops.
Posting for my future reference, but others may also be interested.
Joe