Modern C# – Part 1

This short post will kick off a series covering some of the new features in C#.

One small but much requested feature is the ability to use any kind of collection for params. Previously you had to pass in an array:

   public void MyMethod(int firstParam, params string[] otherParams)
   {
      foreach (var param in otherParams)
      {
         Console.WriteLine(param);
      }
   }

But now you can pass in any kind of collection,

 public void MyMethod(int firstParam, params List<string> otherParams)
 {
    foreach (var param in otherParams)
    {
       Console.WriteLine(param);
    }
 }

This can save a great deal of fussing, converting your collection to an array and back.

Please note that this is a preview feature. Fortunately, Intellisense will convert your project for you. When you put this in you’ll get the dreaded red squiggly. Click on the light bulb and let it convert your project. Hey! Presto! it works.

We’ll look at a few bigger features in coming blog posts.

Unknown's avatar

About Jesse Liberty

** Note ** Jesse is currently looking for a new position. You can learn more about him at https://jesseliberty.bio Thank you. Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET, is now available wherever you buy your books. Liberty was a Team Lead and Senior Software Engineer for various corporations, a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a 13 year Microsoft MVP.
This entry was posted in C#, C# 12, Essentials. Bookmark the permalink.

1,500 Responses to Modern C# – Part 1

  1. Wohh precisely what I was looking for, thankyou for putting up.

  2. Some genuinely select posts on this site, saved to fav.

  3. I dugg some of you post as I cogitated they were handy very beneficial

  4. CBD Cream's avatar CBD Cream says:

    Heya i am for the first time here. I found this board and I find It really useful & it helped me out much. I hope to give something back and aid others like you aided me.

  5. I think you have mentioned some very interesting details, thanks for the post.

  6. try2fa's avatar try2fa says:

    It’s great to see C# finally embracing the flexibility to use any collection with params, which should save developers significant boilerplate when handling variable argument lists. I appreciate the tip about the preview feature and Intellisense auto-conversion—those red squiggles can be intimidating, but it sounds like the workflow is much smoother than expected. Looking forward to the next part to see what other modern features are coming next!

  7. I really appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thx again

  8. 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!

  9. It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

  10. olxtoto's avatar olxtoto says:

    It’s a pity you don’t have a donate button! I’d without a doubt donate to this brilliant 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!

  11. As I website owner I conceive the content here is rattling wonderful, appreciate it for your efforts.

  12. DichaelAlono's avatar DichaelAlono says:

    I am very pleased to have stumbled upon this specific article. It is not always easy to find a fully objective and universally applicable overview, but you have managed to hit all the right notes with your logical formatting and incredibly clear explanations right here.

    купить inmode Morpheus 8

  13. I’ve been browsing online more than 3 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 web will be much more useful than ever before.

  14. spin casino's avatar spin casino says:

    This design is spectacular! You definitely know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  15. 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 placed 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 totally off topic but I had to tell someone!

  16. Great post. I am facing a couple of these problems.

  17. certainly like your web site however you need to take a look at the spelling on several of your posts. Several of them are rife with spelling problems and I find it very bothersome to tell the reality on the other hand I will certainly come back again.

  18. I see something really special in this internet site.

  19. I like this site so much, saved to my bookmarks.

  20. Dead pent written content, Really enjoyed looking at.

  21. I’ve been surfing online more than three hours these days, but I by no means discovered any interesting article like yours. It’s lovely worth sufficient for me. In my opinion, if all web owners and bloggers made good content as you did, the net can be a lot more helpful than ever before. “When the heart speaks, the mind finds it indecent to object.” by Milan Kundera.

  22. ShanepiliA's avatar ShanepiliA says:

    I appreciate how this post combines informative content with a natural and interesting style that makes the discussion more pleasant to read overall.

    no deposit bonus

  23. I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back down the road. Cheers

  24. 55jogo's avatar 55jogo says:

    Appreciate it for all your efforts that you have put in this. very interesting information.

  25. hptoto link's avatar hptoto link says:

    Greetings from Colorado! I’m bored at work so I decided to check out your site on my iphone during lunch break. I enjoy the information you provide here and can’t wait to take a look when I get home. I’m surprised at how quick your blog loaded on my mobile .. I’m not even using WIFI, just 3G .. Anyways, fantastic site!

  26. I’m really loving the theme/design of your web site. Do you ever run into any internet browser compatibility problems? A small number of my blog visitors have complained about my blog not operating correctly in Explorer but looks great in Chrome. Do you have any recommendations to help fix this problem?

  27. I loved as much as you’ll obtain performed right here. The cartoon is tasteful, your authored subject matter stylish. however, you command get got an nervousness over that you want be handing over the following. unwell without a doubt come more before once more since precisely the same just about very continuously inside case you protect this hike.

  28. What i do not understood is in truth how you are not really a lot more well-appreciated than you might be now. You’re very intelligent. You understand therefore significantly when it comes to this matter, produced me in my opinion imagine it from so many varied angles. Its like women and men aren’t involved unless it is something to accomplish with Lady gaga! Your personal stuffs nice. All the time care for it up!

  29. This design is steller! You definitely know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  30. bet86's avatar bet86 says:

    First off I want to say superb blog! I had a quick question in which I’d like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I have had trouble clearing my mind in getting my thoughts out there. I do enjoy writing however it just seems like the first 10 to 15 minutes tend to be wasted simply just trying to figure out how to begin. Any suggestions or hints? Thanks!

  31. phcity's avatar phcity says:

    magnificent submit, very informative. I’m wondering why the opposite experts of this sector do not notice this. You must continue your writing. I am sure, you have a great readers’ base already!

  32. gatotkac's avatar gatotkac says:

    Thanks for all your efforts that you have put in this. very interesting information.

  33. Some truly interesting information, well written and broadly speaking user genial.

  34. link mpo's avatar link mpo says:

    Yay google is my king assisted me to find this outstanding web site! .

  35. Would love to constantly get updated great website! .

  36. I like this website so much, saved to bookmarks. “I don’t care what is written about me so long as it isn’t true.” by Dorothy Parker.

  37. Precisely what I was searching for, thanks for putting up.

  38. It’s truly a nice and helpful piece of info. I am happy that you simply shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.

  39. audileaf's avatar audileaf says:

    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.

  40. Dead written written content, thankyou for entropy.

  41. Discover how SBLC and Bank Guarantee monetization works in trade finance, including liquidity access, structured funding, risk management, and global trade financing solutions.

  42. olxtoto link's avatar olxtoto link says:

    Thanks for another great post. Where else could anybody get that kind of info in such a perfect way of writing? I’ve a presentation next week, and I am on the look for such info.

  43. I appreciate, cause I found just what I was looking for. You have ended my 4 day long hunt! God Bless you man. Have a great day. Bye

  44. whoah this blog is fantastic i love reading your articles. Keep up the good work! You know, many people are searching around for this info, you can aid them greatly.

  45. Hey! Do you know if they make any plugins to safeguard against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?

  46. Hello there, just was aware of your weblog through Google, and located that it’s really informative. I’m gonna watch out for brussels. I’ll appreciate when you proceed this in future. Many folks might be benefited out of your writing. Cheers!

  47. Hello my friend! I want to say that this article is awesome, nice written and include almost all important infos. I’d like to see more posts like this.

  48. heictopng's avatar heictopng says:

    The ability to use any collection type directly in the `params` keyword is a huge time-saver that eliminates so much unnecessary boilerplate code for array conversions. Kudos to you for breaking down this preview feature so clearly, especially with those helpful Intelliense tips for handling the red squiggly lines.

  49. Refreshing to see how the new ‘params for any collection’ feature is finally streamlining what used to be such a tedious conversion process. I particularly appreciate the note about the preview nature of this feature; the auto-conversion via IntelliSense will definitely speed up adoption without forcing immediate manual refactors. Looking forward to seeing the other major updates in the next part of the series.

  50. I and my guys came following the good things found on your website and suddenly got an awful feeling I had not thanked you for them. The ladies appeared to be certainly joyful to learn them and now have truly been loving these things. Appreciate your being well helpful and also for considering some impressive issues most people are really desirous to understand about. Our own honest apologies for not expressing appreciation to you sooner.

Comments are closed.