System.Linq and TakeLast() not defined.
Hi.
I am going through the book Head First C# and in chapter 9 when they introduce LINQ I am getting a weird error. I tried to google my problem but I couldn't find a solution.
The book has me calling the method TakeLast() on a list. However Visual Studio is telling me that method is not defined. All I could find on the internet is to make sure I am using System.Linq. Which I am.
I made sure my project properties is using the latest version of C#.
I am really lost about this. Was TakeLast() removed ?
7 Replies
i think it's the opposite problem, you're using an older version of .NET that doesn't have it
make sure you're using .NET 8
if you're using anything that says .NET Framework that's old and should be avoided
Ok Thank you very much that is the problem. I am using .NET Framework 4.7.2....
I will install the new version. 🙏🙏🙏
:SCshocked:
4.7.2 is beyond old
Yup I created the project using .NET Framework console App template without realizing. It defaulted to that version
$newproject
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework.
.NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended.
https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
For future reference