Until now, if you wanted to access the last item in a list you had to use a slightly cumbersome syntax. C# 13 introduces the “hat” operator (^) where ^1 is the last element in your collection, ^2 is the penultimate member, etc.
Like many things, this is best illustrated with an example. In the following code I create a simple Person class and initialize a list<Person> with three people (persons?)
internal class Program
{
static void Main(string[] args)
{
var tester = new Tester();
tester.Test();
}
}
public class Tester()
{
public void Test()
{
var john = new Person { Name = "John", Age = 25 };
var jane = new Person { Name = "Jane", Age = 30 };
var joe = new Person { Name = "Joe", Age = 35 };
var people = new List<Person> { john, jane, joe };
}
}
public class Person()
{
public string Name { get; set; }
public int Age { get; set; }
}
Straight forward. Now, if I want to access the last person in this list I can write
var lastPerson = people[^1];
Console.WriteLine($"Last person is {lastPerson.Name} who is {lastPerson.Age} years old.");
As you can see, this is concise and easy to understand. You read it as “lastPerson is equal to one back from the end of people.” Let’s run it:
Last person is Joe who is 35 years old.
That is all there is to it. Easy to use and somewhat helpful in simplifying your code.

I am constantly browsing online for posts that can help me. Thank you!
The Pink Salt Trick is a minimalist but effective morning routine: Just drink a glass of lukewarm water mixed with a pinch of Himalayan pink salt as soo
Fantastic web site. A lot of useful information here. I am sending it to several pals ans also sharing in delicious. And certainly, thank you to your sweat!
Pretty nice post. I just stumbled upon your blog and wanted to say that I have truly enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!
The Pink Salt Trick is a minimalist but effective morning routine: Just drink a glass of lukewarm water mixed with a pinch of Himalayan pink salt as soo
Some genuinely wondrous work on behalf of the owner of this site, absolutely outstanding subject material.
Great write-up, I?¦m normal visitor of one?¦s blog, maintain up the excellent operate, and It is going to be a regular visitor for a lengthy time.
The Pink Salt Trick is a minimalist but effective morning routine: Just drink a glass of lukewarm water mixed with a pinch of Himalayan pink salt as soo
I have been exploring for a bit for any high-quality articles or blog posts on this sort of house . Exploring in Yahoo I finally stumbled upon this website. Studying this information So i’m satisfied to convey that I have an incredibly just right uncanny feeling I found out just what I needed. I most definitely will make certain to don’t put out of your mind this web site and provides it a glance on a continuing basis.
Hey There. I discovered your blog the usage of msn. This is a really well written article. I’ll make sure to bookmark it and come back to learn more of your helpful information. Thank you for the post. I will certainly return.
Hi, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!
Very interesting info!Perfect just what I was searching for!
You are a very clever individual!
I’ve read a few good stuff here. Definitely worth bookmarking for revisiting. I wonder how much effort you put to create such a wonderful informative site.
I like this blog very much so much good information.
Hello, Neat post. There is a problem with your web site in internet explorer, might check thisK IE nonetheless is the marketplace chief and a large component of folks will miss your excellent writing due to this problem.
516704 807009Great day! Do you know if they make any plugins to protect against hackers? Im kinda paranoid about losing everything Ive worked hard on. Any guidelines? 713677
Thanks a lot for giving everyone an extraordinarily nice possiblity to read articles and blog posts from here. It is always so good and also packed with a lot of fun for me personally and my office peers to search your website at the least 3 times in one week to read through the latest stuff you will have. Not to mention, I’m so at all times satisfied with the great tricks you serve. Certain 2 points in this article are easily the most beneficial we have had.
Merely a smiling visitant here to share the love (:, btw outstanding design. “Treat the other man’s faith gently it is all he has to believe with.” by Athenus.
Youre so cool! I dont suppose Ive learn anything like this before. So nice to seek out someone with some unique ideas on this subject. realy thank you for beginning this up. this web site is something that’s needed on the net, someone with just a little originality. helpful job for bringing one thing new to the web!
What i don’t realize is in fact how you’re not actually a lot more well-liked than you may be now. You’re very intelligent. You already know therefore significantly with regards to this subject, made me in my opinion believe it from so many numerous angles. Its like women and men don’t seem to be interested until it is something to accomplish with Woman gaga! Your own stuffs excellent. Always take care of it up!
Can I just say what a aid to search out somebody who truly is aware of what theyre talking about on the internet. You undoubtedly know how you can deliver a difficulty to mild and make it important. More individuals must learn this and understand this facet of the story. I cant imagine youre not more well-liked because you definitely have the gift.
amei este site. Pra saber mais detalhes acesse nosso site e descubra mais. Todas as informações contidas são conteúdos relevantes e diferentes. Tudo que você precisa saber está está lá.
This article is so valuable, I have recommended it to my colleagues, and I also wrote an experience article myself
I loved as much as you will receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this increase.
I like this web blog its a master peace ! Glad I detected this on google .
What i don’t realize is if truth be told how you are now not really much more neatly-preferred than you may be right now. You’re so intelligent. You realize therefore considerably with regards to this subject, made me individually imagine it from so many varied angles. Its like women and men don’t seem to be involved until it’s something to do with Girl gaga! Your personal stuffs outstanding. Always handle it up!
After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.
You have remarked very interesting points! ps nice website.
781537 795061Hey there! Nice stuff, please maintain me posted when you post something like this! 871147
Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get in fact enjoyed account your blog posts. Anyway I will be subscribing to your augment and even I achievement you access consistently quickly.
There are definitely quite a lot of details like that to take into consideration. That is a great level to deliver up. I offer the ideas above as basic inspiration however clearly there are questions like the one you bring up where the most important factor will probably be working in sincere good faith. I don?t know if best practices have emerged round issues like that, however I am certain that your job is clearly recognized as a good game. Each boys and girls feel the impression of just a second’s pleasure, for the rest of their lives.
I beloved up to you’ll receive carried out proper here. The caricature is tasteful, your authored material stylish. nevertheless, you command get got an edginess over that you would like be turning in the following. ill without a doubt come further in the past again since precisely the same just about very regularly inside case you shield this increase.
Definitely believe that which you stated. Your favorite reason appeared to be on the net the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they plainly don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks
As a newbie in this field, this article is very practical for me. I hope to continue to update it!
911634 993373This douche bag loves his illegal bretheren because hes a itiaen with the world and we need to be ashamed of ourselves I got news for you Asswipe get your asswiping ass back to the craphole where you came from with all of your illegal beaners 579944
468760 628402I agree with you. I wish I had your blogging style. 68199
I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100 sure. Any suggestions or advice would be greatly appreciated. Thank you
demais este conteúdo. Gostei muito. Aproveitem e vejam este conteúdo. informações, novidades e muito mais. Não deixem de acessar para se informar mais. Obrigado a todos e até mais. 🙂
503043 750382I consider something truly fascinating about your web site so I saved to fav. 436384
Thank you for sharing your dry goods, I have been looking for similar content, and I also wrote some experience notes and posted them on:搜狗输入法下载
Great post. I was checking continuously this blog and I’m impressed! Very helpful info specifically the last part 🙂 I care for such info much. I was seeking this certain information for a very long time. Thank you and best of luck.
Hi! This post could not be written any better! Reading this post reminds me of my previous room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Thank you for sharing!
Hi, Neat post. There is an issue together with your website in web explorer, might check this?K IE nonetheless is the marketplace chief and a huge section of other people will omit your magnificent writing because of this problem.
Thank you, I have just been looking for info about this subject for ages and yours is the best I have discovered so far. But, what about the conclusion? Are you sure about the source?
dvjcxy
yt2ddh
ibuw3f
It¦s really a great and helpful piece of info. I¦m satisfied that you shared this helpful information with us. Please stay us informed like this. Thanks for sharing.
I’m not sure where you are getting your information, but good topic. I needs to spend some time learning much more or understanding more. Thanks for excellent info I was looking for this info for my mission.