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 got what you intend,saved to fav, very decent website .
I genuinely enjoy looking at on this web site, it has great content. “Beware lest in your anxiety to avoid war you obtain a master.” by Demosthenes.
You could definitely see your enthusiasm within the paintings you write. The world hopes for more passionate writers like you who aren’t afraid to mention how they believe. All the time follow your heart.
Pretty! This was a really wonderful post. Thank you for your provided information.
Lovely just what I was searching for.Thanks to the author for taking his clock time on this one.
Incredible! This blog looks exactly like my old one! It’s on a completely different subject but it has pretty much the same layout and design. Great choice of colors!
Its like you learn my thoughts! You seem to understand a lot about this, like you wrote the e-book in it or something. I believe that you just can do with some to power the message home a little bit, however other than that, this is excellent blog. A great read. I will definitely be back.
Saved as a favorite, I really like your blog!
The crux of your writing whilst sounding reasonable at first, did not really settle very well with me after some time. Somewhere within the paragraphs you actually managed to make me a believer but just for a short while. I nevertheless have a problem with your jumps in assumptions and you would do well to fill in all those gaps. If you can accomplish that, I would surely be fascinated.
I have been browsing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.
hello there and thank you for your information – I have definitely picked up anything new from right here. I did however expertise some technical issues using this web site, as I experienced to reload the web site many times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your quality score if advertising and marketing with Adwords. Well I’m adding this RSS to my e-mail and could look out for a lot more of your respective intriguing content. Make sure you update this again very soon..
Hi! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be bookmarking and checking back often!
I dugg some of you post as I cogitated they were very helpful very helpful
I’m not that much of a internet reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your site to come back in the future. Cheers
I likewise conceive hence, perfectly indited post! .
I am not very wonderful with English but I get hold this very easygoing to interpret.
hello!,I love your writing so so much! percentage we communicate more approximately your post on AOL? I need a specialist on this house to solve my problem. May be that is you! Taking a look forward to see 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 soon as you wake up.
It’s exhausting to search out knowledgeable individuals on this matter, but you sound like you understand what you’re talking about! Thanks
I enjoy the efforts you have put in this, regards for all the great posts.
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!
I delight in, result in I found just what I used to be taking a look for. You have ended my four day long hunt! God Bless you man. Have a great day. Bye
I have been absent for a while, but now I remember why I used to love this blog. Thank you, I will try and check back more often. How frequently you update your website?
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!
I have been checking out some of your articles and i must say nice stuff. I will definitely bookmark your website.
I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.
Today, I went to the beach front with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!
I have read a few just right stuff here. Definitely price bookmarking for revisiting. I surprise how a lot effort you set to make this kind of magnificent informative web site.
Hi, I think your site might be having browser compatibility issues. When I look at your blog site 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, excellent blog!
Loving the info on this website , you have done outstanding job on the posts.
Sleep Lean is a natural supplement designed to improve sleep quality and aid weight loss while you sleep.
After I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any means you can take away me from that service? Thanks!
You could definitely see your enthusiasm in the paintings you write. The world hopes for even more passionate writers like you who aren’t afraid to say how they believe. At all times go after your heart. “History is the version of past events that people have decided to agree upon.” by Napoleon.
magnificent post, very informative. I wonder why the other specialists of this sector don’t notice this. You must continue your writing. I’m sure, you’ve a huge readers’ base already!
Lipovive acts on the metabolism, burning fat, reducing appetite, and providing more energy.
I got good info from your blog
I believe this is among the so much vital info for me. And i am glad studying your article. But should remark on few normal issues, The site taste is ideal, the articles is actually nice : D. Just right process, cheers
It’s hard to seek out knowledgeable people on this topic, however you sound like you recognize what you’re speaking about! Thanks
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.
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 soon as you wake up.
Definitely, what a splendid website and informative posts, I definitely will bookmark your website.Best Regards!
I think this is one of the most significant information for me. And i’m glad reading your article. But want to remark on few general things, The site style is great, the articles is really nice : D. Good job, cheers
Merely a smiling visitant here to share the love (:, btw outstanding design and style.
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 soon as you wake up.
I have learn some good stuff here. Definitely worth bookmarking for revisiting. I wonder how so much effort you put to make any such magnificent informative web site.
I besides conceive hence, perfectly written post! .
I am not positive where you’re getting your info, however good topic. I needs to spend some time studying more or understanding more. Thank you for great information I was searching for this information for my mission.
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 soon as you wake up.
Some genuinely nice and useful info on this site, as well I conceive the style has great features.
I’m not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for excellent info I was looking for this information for my mission.