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.

My partner and I stumbled over here coming from a different web address and thought I might check things out. I like what I see so now i’m following you. Look forward to looking into your web page again.
Great wordpress blog here.. It’s hard to find quality writing like yours these days. I really appreciate people like you! take care
That is the correct weblog for anyone who needs to search out out about this topic. You notice a lot its virtually arduous to argue with you (not that I actually would want…HaHa). You undoubtedly put a brand new spin on a topic thats been written about for years. Nice stuff, just nice!
Very interesting information!Perfect just what I was looking for! “Some people don’t get it when I’m being sarcastic.” by Leonardo DiCaprio.
Thanks , I’ve just been searching for info approximately this topic for ages and yours is the greatest I have found out till now. However, what concerning the bottom line? Are you certain about the source?
https://vodamarket.od.ua/linzy-v-fary-audi-q5-yak-pokrashchyty-svitlo-dlya.html
You must take part in a contest for among the finest blogs on the web. I will advocate this website!
Hi! I’m at work surfing around your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the superb work!
Generic Viagra for sale CoreBlue Health Generic Viagra for sale
I have been surfing on-line more than three hours nowadays, but I never discovered any fascinating article like yours. It is pretty value enough for me. Personally, if all website owners and bloggers made excellent content as you did, the internet will be much more useful than ever before. “Wherever they burn books, they will also, in the end, burn people.” by Heinrich Heine.
You made some nice points there. I looked on the internet for the subject matter and found most guys will consent with your site.
It’s really a nice and helpful piece of information. I am glad that you shared this useful info with us. Please keep us up to date like this. Thanks for sharing.
Thanks for the sensible critique. Me and 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 from this post. I’m very glad to see such magnificent info being shared freely out there.
I really like your writing style, excellent info , thankyou for putting up :D.
I think other web-site proprietors should take this website as an model, very clean and wonderful user genial style and design, let alone the content. You are an expert in this topic!
Would you be excited by exchanging hyperlinks?
I like what you guys tend to be up too. Such clever work and coverage! Keep up the good works guys I’ve included you guys to my personal blogroll.
I went over this site and I think you have a lot of great info , saved to my bookmarks (:.
buy medicines online in india: indian pharmacies safe – mail order pharmacy india
Howdy would you mind stating which blog platform you’re working with? I’m planning to start my own blog in the near future but I’m having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique. P.S My apologies for getting off-topic but I had to ask!
After study just a few of the blog posts on your web site now, and I really like your way of blogging. I bookmarked it to my bookmark web site checklist and will be checking again soon. Pls try my web page as nicely and let me know what you think.
Aw, this was a really nice post. In concept I would like to put in writing like this additionally – taking time and precise effort to make a very good article… however what can I say… I procrastinate alot and in no way seem to get something done.
Hi there, 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 remarks? If so how do you protect against it, any plugin or anything you can recommend? I get so much lately it’s driving me crazy so any help is very much appreciated.
Hi, I think your site might be having browser compatibility issues. When I look at your website in Chrome, 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, superb blog!
Just a smiling visitant here to share the love (:, btw outstanding layout.
Great web site. A lot of useful information here. I am sending it to a few buddies ans also sharing in delicious. And certainly, thank you on your sweat!
You are a very smart individual!
This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your excellent post. Also, I have shared your website in my social networks!
I believe this web site has very great composed articles content.
You have remarked very interesting details! ps nice site. “There’s always one who loves and one who lets himself be loved.” by W. Somerset Maugham.
I have been exploring for a little bit for any high quality articles or blog posts on this sort of house . Exploring in Yahoo I eventually stumbled upon this website. Reading this information So i am satisfied to exhibit that I’ve a very just right uncanny feeling I came upon just what I needed. I so much for sure will make certain to don’t overlook this web site and provides it a look regularly.
Have you ever thought about creating an ebook or guest authoring on other websites? I have a blog based upon on the same ideas you discuss and would really like to have you share some stories/information. I know my subscribers would appreciate your work. If you’re even remotely interested, feel free to shoot me an e-mail.
Thank you a bunch for sharing this with all of us you really realize what you’re speaking about! Bookmarked. Kindly also seek advice from my website =). We will have a hyperlink exchange arrangement among us!
I really thankful to find this web site on bing, just what I was searching for : D too saved to bookmarks.
You have remarked very interesting details! ps decent website.
An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!
Thanks for sharing excellent informations. Your site is so cool. I’m impressed by the details that you have on this blog. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found simply the information I already searched all over the place and simply could not come across. What an ideal site.
https://ivermectinfast.shop/# antiparasitic medication usa
obviously like your website but you need to check the spelling on quite a few of your posts. Several of them are rife with spelling issues and I find it very troublesome to inform the truth nevertheless I’ll certainly come back again.
Would you be serious about exchanging hyperlinks?
prednisone 5 mg tablet cost: prednisone for inflammation treatment – buy prednisone online paypal
Good info. Lucky me I reach on your website by accident, I bookmarked it.
amoxil without prescription usa: bacterial infection medication – buy amoxicillin 500mg usa
ivermectin fast: parasite infection medication – antiparasitic medication usa
Hmm it looks like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing. Do you have any suggestions for beginner blog writers? I’d certainly appreciate it.
It’s in reality a great and helpful piece of information. I am happy that you simply shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.
I really like your writing style, superb info, thanks for putting up :D. “Kennedy cooked the soup that Johnson had to eat.” by Konrad Adenauer.
https://ivermectinfast.shop/# ivermectin 2ml
We absolutely love your blog and find many of your post’s to be just what I’m looking for. can you offer guest writers to write content for you personally? I wouldn’t mind composing a post or elaborating on a number of the subjects you write regarding here. Again, awesome website!
https://teletype.in/@avtobloggerua/B8-lsvQ4Hyu
After I initially commented I clicked the -Notify me when new feedback are added- checkbox and now every time a comment is added I get 4 emails with the identical comment. Is there any approach you’ll be able to remove me from that service? Thanks!
I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.