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.

Wonderful post however I was wondering if you could write a litte more on this topic? I’d be very thankful if you could elaborate a little bit more. Thank you!
Valuable information. Lucky me I found your website by accident, and I am shocked why this accident did not happened earlier! I bookmarked it.
The subsequent time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my choice to learn, but I actually thought youd have one thing attention-grabbing to say. All I hear is a bunch of whining about something that you could repair when you werent too busy in search of attention.
830652 566721Truly nice style and style and outstanding content material , nothing at all else we require : D. 881911
Excellent goods from you, man. I have understand your stuff previous to and you are just extremely wonderful. I really like what you have acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it sensible. I can’t wait to read much more from you. This is actually a wonderful website.
A person essentially lend a hand to make significantly articles I would state. This is the first time I frequented your website page and thus far? I surprised with the analysis you made to make this particular submit extraordinary. Fantastic task!
Good day very nice web site!! Man .. Excellent .. Amazing .. I will bookmark your blog and take the feeds also…I’m glad to search out so many useful information right here in the put up, we want work out extra strategies in this regard, thanks for sharing.
Hello, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you protect against it, any plugin or anything you can suggest? I get so much lately it’s driving me crazy so any assistance is very much appreciated.
The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.
great issues altogether, you simply received a logo new reader. What could you suggest about your post that you just made some days in the past? Any sure?
I am no longer certain where you are getting your information, however great topic. I needs to spend a while learning more or working out more. Thanks for wonderful information I was searching for this information for my mission.
Sweet internet site, super style and design, very clean and utilise pleasant.
Very interesting subject, appreciate it for putting up. “Education a debt due from present to future generations.” by George Peabody.
I’d have to examine with you here. Which isn’t something I usually do! I take pleasure in studying a post that may make people think. Also, thanks for allowing me to comment!
Heya i’m for the first time here. I came across this board and I in finding It truly helpful & it helped me out a lot. I’m hoping to present something again and help others such as you helped me.
This really answered my problem, thank you!
I think this is among the most significant information for me. And i am glad reading your article. But want to remark on few general things, The site style is great, the articles is really excellent : D. Good job, cheers
I have not checked in here for a while because I thought it was getting boring, but the last few posts are great quality so I guess I?¦ll add you back to my daily bloglist. You deserve it my friend 🙂
I do love the way you have framed this situation plus it does indeed give me a lot of fodder for consideration. Nonetheless, through just what I have witnessed, I just trust as the remarks pack on that folks continue to be on issue and don’t embark on a tirade involving some other news du jour. Anyway, thank you for this fantastic piece and whilst I do not really go along with the idea in totality, I respect the standpoint.
The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.
Hello, you used to write magnificent, but the last several posts have been kinda boring… I miss your tremendous writings. Past several posts are just a little out of track! come on!
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.
What i do not understood is in truth how you’re not really a lot more smartly-favored than you may be right now. You’re so intelligent. You recognize thus significantly in terms of this topic, made me individually imagine it from so many various angles. Its like women and men don’t seem to be fascinated until it’s something to do with Woman gaga! Your personal stuffs great. At all times take care of it up!
Flash Burn is a revolutionary natural supplement that has been transforming the lives of thousands of people struggling with excess weight. Developed with a 100 natural and scientifically proven formula
I will right away seize your rss as I can not find your e-mail subscription link or e-newsletter service. Do you’ve any? Kindly permit me realize in order that I may subscribe. Thanks.
he blog was how do i say it… relevant, finally something that helped me. Thanks
I am glad to be a visitor of this consummate web site! , appreciate it for this rare info ! .
Wow, fantastic weblog layout! How long have you been running a blog for? you made blogging look easy. The total glance of your site is excellent, as smartly as the content!
Just desire to say your article is as astounding. The clarity on your publish is just excellent and i can think you’re an expert in this subject. Well together with your permission let me to grab your feed to stay updated with impending post. Thanks 1,000,000 and please keep up the rewarding work.
I think this is one of the most vital information for me. And i’m glad reading your article. But should remark on few general things, The website style is ideal, the articles is really excellent : D. Good job, cheers
I wish to express some thanks to you just for bailing me out of this situation. After looking through the internet and obtaining proposals which are not beneficial, I was thinking my entire life was over. Living without the presence of approaches to the issues you’ve fixed by means of your entire blog post is a serious case, and those that would have in a wrong way damaged my entire career if I hadn’t encountered the blog. Your own personal capability and kindness in dealing with every item was priceless. I don’t know what I would have done if I had not encountered such a step like this. I’m able to now look ahead to my future. Thanks very much for the expert and sensible help. I won’t think twice to propose your blog to anyone who wants and needs assistance on this situation.
You should take part in a contest for one of the best blogs on the web. I will recommend this site!
I really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again
I enjoy the efforts you have put in this, thank you for all the great articles.
I do trust all of the concepts you’ve presented on your post. They’re really convincing and can definitely work. Nonetheless, the posts are too brief for newbies. May just you please lengthen them a bit from subsequent time? Thank you for the post.
Keep working ,splendid job!
You actually make it seem so easy with your presentation but I find this matter to be really something which I think I would never understand. It seems too complex and very broad for me. I am looking forward for your next post, I’ll try to get the hang of it!
An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers
Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your webpage? My website is in the very same niche as yours and my visitors would truly benefit from a lot of the information you provide here. Please let me know if this ok with you. Thanks a lot!
I haven’t checked in here for a while because I thought it was getting boring, but the last few posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂
I like this website very much, Its a rattling nice place to read and find information. “‘Taint’t worthwhile to wear a day all out before it comes.” by Sarah Orne Jewett.
Hi, i believe that i noticed you visited my web site thus i got here to “go back the prefer”.I am trying to in finding things to improve my site!I guess its good enough to use a few of your concepts!!
you’re in reality a good webmaster. The website loading pace is incredible. It seems that you’re doing any distinctive trick. In addition, The contents are masterpiece. you’ve performed a magnificent activity on this topic!
Amazing blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple adjustements would really make my blog jump out. Please let me know where you got your theme. Kudos
Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store. I’d prefer to use some with the content on my blog whether you don’t mind. Natually I’ll give you a link on your web blog. Thanks for sharing.
Thanks for the sensible critique. Me & my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more clear from this post. I’m very glad to see such magnificent information being shared freely out there.
Some really good information, Sword lily I found this. “Good teaching is one-fourth preparation and three-fourths theater.” by Gail.
It’s a shame you don’t have a donate button! I’d definitely donate to this fantastic blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will share this site with my Facebook group. Talk soon!
naturally like your website but you have to test the spelling on quite a few of your posts. A number of them are rife with spelling problems and I to find it very troublesome to inform the truth however I will certainly come back again.
I will right away grasp your rss feed as I can not find your email subscription link or e-newsletter service. Do you have any? Kindly permit me know so that I could subscribe. Thanks.