I have installed the C# Dev kit (it says version 1.10.16). And you might think that it would tell you right up front if it was C# 8, 10, or 12 or whatever. It doesn't.
My project, when I build it, has paths like:
/home/tom/vscode/Socket/bin/Debug/net8.0/Socket.dllAha. So, this mention of "net8.0" hints that this is .NET core 8 -- which implies C# 12, i.e. the latest version of C# -- but I am just assuming this, or deducing it. I would be much happier if it would just tell me.
If I was a true C# Guru, I would know the latest features introduced in C# 12 and could write some code that would test for the presence or absence of those features, but Why should I have to do such a thing?
I'm not a C# Guru (yet, anyway), but the new features described above are not that hard to comprehend.According to the above, "C# 12 introduces collection expressions, primary constructors for all classes and structs, syntax to alias any type, and default parameters for lambda expressions that simplify your code."
Let's try the first one (a collection expression).
I toss a method that looks like the following into one of my classes,
make sure I call it so that it doesn't get optimized out or bypassed, and see if it will build.
It does.
public static void trycs12 () { int[] x1 = [1, 2, 3, 4]; int[] x2 = []; }According to the page above, this syntax is a collection expression and should only be present in C# 12 -- so apparently this is C# 12. And this is consistent with my having .NET 8 on my linux machine.
I guess I am satisfied, and I suppose I have learned something along the way, but ....
Tom's Computer Info / [email protected]