<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JKC</title>
    <description>The latest articles on DEV Community by JKC (@iamprincejkc).</description>
    <link>https://dev.to/iamprincejkc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F820392%2Fd8052783-fad7-46ae-8c9e-61391ecff65a.jpeg</url>
      <title>DEV Community: JKC</title>
      <link>https://dev.to/iamprincejkc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamprincejkc"/>
    <language>en</language>
    <item>
      <title>💎 .NET 9 Hidden Gems: 7 Power Features Most Developers Are Missing</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Sat, 16 Aug 2025 04:02:46 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/net-9-hidden-gems-7-power-features-most-developers-are-missing-26hk</link>
      <guid>https://dev.to/iamprincejkc/net-9-hidden-gems-7-power-features-most-developers-are-missing-26hk</guid>
      <description>&lt;p&gt;.NET 9 has been out for almost a year now, but most developers are still using it like .NET 8.&lt;/p&gt;

&lt;p&gt;The real gains aren't in the headline features. They're in the overlooked improvements that solve daily friction.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hidden Arsenal
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SearchValues for Strings&lt;/strong&gt;&lt;br&gt;
 .NET 8 had SearchValues for chars. .NET 9 etends it to strings with SIMD optimizations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;SearchValues&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BadWords&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; 
     &lt;span class="n"&gt;SearchValues&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;"spam"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"scam"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;StringComparison&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OrdinalIgnoreCase&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;ContainsSuspiciousContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
     &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AsSpan&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;ContainsAny&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BadWords&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Task.WhenEach for Async Processing&lt;/strong&gt;&lt;br&gt;
 Process async operations as they complete instead of waiting for all.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt; &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetStringAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

 &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WhenEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nf"&gt;ProcessImmediately&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;UnsafeAccessor with Generics&lt;/strong&gt;&lt;br&gt;
.NET 8 introduced UnsafeAccessor. .NET 9 adds generic support for zerooverhead private access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;UnsafeAccessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UnsafeAccessorKind&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"_value"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;etern&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;ref&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;GetPrivateField&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;Cache&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// In tests: direct access without reflection overhead&lt;/span&gt;
&lt;span class="k"&gt;ref&lt;/span&gt; &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;ref&lt;/span&gt; &lt;span class="nf"&gt;GetPrivateField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Frozen Collections for Performance&lt;/strong&gt;&lt;br&gt;
Read-optimized collections that are 40% faster for lookups.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;FrozenSet&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ValidEtensions&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; 
     &lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;".jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;".png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;".pdf"&lt;/span&gt; &lt;span class="p"&gt;}.&lt;/span&gt;&lt;span class="nf"&gt;ToFrozenSet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;IsValidFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
     &lt;span class="n"&gt;ValidEtensions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetEtension&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DATAS Garbage Collection&lt;/strong&gt;&lt;br&gt;
Dynamic adaptation is now enabled by default. Your GC automatically adjusts heap size based on workload. No code changes needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;These features solve specific performance and productivity pain points that add up over time.&lt;/p&gt;

&lt;p&gt;Multi-string search becomes efficient. Async coordination gets simpler. Testing private members becomes fast. Collection lookups get faster. Memory management becomes smarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reality
&lt;/h2&gt;

&lt;p&gt;Most teams ship .NET 9 apps that perform like .NET 6 because they stick to old patterns.&lt;/p&gt;

&lt;p&gt;The developers using these features are already building faster systems while others struggle with familiar bottlenecks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;I've been running .NET 9 in production for months now, and honestly, I can't go back.&lt;/p&gt;

&lt;p&gt;When I see 20-30% faster response times and better memory usage, sticking with older versions feels like driving with the parking brake on. The performance gains aren't just &lt;em&gt;nice to have&lt;/em&gt; anymore, they're real money left on the table."&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>👾 GPT 5 is coming and it might be smarter than Sam Altman</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Thu, 10 Jul 2025 14:49:04 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/gpt-5-is-coming-and-it-might-be-smarter-than-sam-altman-4bm8</link>
      <guid>https://dev.to/iamprincejkc/gpt-5-is-coming-and-it-might-be-smarter-than-sam-altman-4bm8</guid>
      <description>&lt;h2&gt;
  
  
  GPT-5 is Coming: The AI Revolution You're Not Ready For
&lt;/h2&gt;

&lt;p&gt;GPT-5 is launching soon. OpenAI is aiming for a release between July and September 2025, and it will be free to use.&lt;/p&gt;

&lt;p&gt;Sam Altman, the CEO of OpenAI, recently said that GPT-5 may already be smarter than he is. That's not a marketing line, it's a clear signal that AI is entering a new phase.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Different This Time
&lt;/h2&gt;

&lt;p&gt;You won't need to choose between models anymore. GPT-5 is built as a single, unified system that adapts to whatever task you give it. Whether you're coding, writing, researching, or creating content, it just works.&lt;/p&gt;

&lt;p&gt;It now reasons by default. You don't have to prompt it to think through steps—it already does.&lt;/p&gt;

&lt;p&gt;It also remembers. GPT-5 learns your tone, your goals, and your working style across sessions.&lt;/p&gt;

&lt;p&gt;You can talk to it, upload images or files, and it understands everything in one conversation. And thanks to its epanded memory, it can handle huge amounts of contet—full books, long chats, or entire project documents.&lt;/p&gt;

&lt;p&gt;The biggest shift might be that GPT-5 doesn't just wait for instructions. It takes initiative based on what it sees and what you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;For developers, GPT-5 can write production-ready code, fi bugs, and even help design systems. You'll get work done faster, with fewer manual steps.&lt;/p&gt;

&lt;p&gt;For founders, it can act like a partner—helping with strategy, marketing, and eecution without needing a full team.&lt;/p&gt;

&lt;p&gt;For creators, the content pipeline becomes much smoother. You bring the idea, and GPT-5 helps shape everything else around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Stands Out
&lt;/h2&gt;

&lt;p&gt;Other models like Claude, Gemini, and Grok each have strengths. Claude is great at research. Gemini does well with visuals. Grok is strong on live social data.&lt;/p&gt;

&lt;p&gt;GPT-5 is aiming to do all of it. One model, one interface, full capability, grow the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;GPT-5 is not just another release. It's a shift in how we'll build, create, and work moving forward.&lt;/p&gt;

&lt;p&gt;The question is no longer if it will change everything.&lt;/p&gt;

&lt;p&gt;The real question is how fast you're ready to move.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>developers</category>
      <category>news</category>
    </item>
    <item>
      <title>5 Best New Features in .NET 9 &amp; 10 That Every Developer Should Know</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Thu, 12 Jun 2025 15:37:30 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/5-best-new-features-in-net-9-10-that-every-developer-should-know-4n3j</link>
      <guid>https://dev.to/iamprincejkc/5-best-new-features-in-net-9-10-that-every-developer-should-know-4n3j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I’ve worked with nearly every .NET version in real-world projects, and every major release brings something that either surprises me or genuinely boosts my productivity. With .NET 9 and .NET 10, Microsoft has really stepped up their game these aren’t just incremental updates, but feature drops that can change how you architect and ship your software. If you’re maintaining legacy APIs or jumping into greenfield cloud apps, there’s plenty to get excited about. Here’s a quick rundown of the five features that made me stop, dig in, and say “wow, this is going to save time.&lt;br&gt;
&lt;em&gt;Explore the official release notes:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-9/overview" rel="noopener noreferrer"&gt;.NET 9 What's New &lt;/a&gt;&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-10/overview" rel="noopener noreferrer"&gt;.NET 10 What's New&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Native AOT (Ahead-of-Time Compilation) for All App Types
&lt;/h2&gt;

&lt;p&gt;One of the pain points I’ve run into especially with microservices or background tasks is startup lag and heavy memory usage. Native AOT changes the rules. Now, you can compile your .NET code straight to native binaries, meaning apps launch instantly, use less memory, and don’t drag the entire .NET runtime along for the ride. This is especially huge for anyone pushing containers or building serverless functions.&lt;/p&gt;

&lt;p&gt;How to enable Native AOT in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PublishAot&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/PublishAot&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Publish your app as a native executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet publish &lt;span class="nt"&gt;-c&lt;/span&gt; Release &lt;span class="nt"&gt;-r&lt;/span&gt; win-x64 &lt;span class="nt"&gt;--self-contained&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt;:PublishAot&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Built-in OpenTelemetry and Observability
&lt;/h2&gt;

&lt;p&gt;Tracing and monitoring used to mean fighting with extra NuGet packages or gluing together logging libraries. With .NET 9/10, OpenTelemetry is built right in. The first time I saw distributed tracing flow from ASP.NET Core through my data layer without much config, I was honestly relieved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatic tracing and metrics&lt;/li&gt;
&lt;li&gt;Easier integration with popular monitoring tools&lt;/li&gt;
&lt;li&gt;Better visibility into distributed systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. C# 13: Primary Constructors and More
&lt;/h2&gt;

&lt;p&gt;I’m a huge fan of anything that helps me write less boilerplate and keeps code clean. C# 13’s Primary Constructors for classes do exactly that. No more repetitive constructor assignments just declare your parameters once, and you’re set.&lt;/p&gt;

&lt;p&gt;Here’s a quick example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Email&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Besides that, lambdas and pattern matching keep improving every release, and string interpolation is now both faster and safer. All these little changes add up and make daily coding genuinely nicer.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. ASP.NET Core: Strongly Typed Minimal APIs with Source Generators
&lt;/h2&gt;

&lt;p&gt;Minimal APIs were already a breath of fresh air for small services, but .NET 10 takes it up a notch. The new source generators make reflection mostly a thing of the past, and you get full type safety for your endpoints. It’s the sort of feature that makes refactoring APIs less nerve-wracking and really speeds up the "write it, test it, ship it" cycle.&lt;/p&gt;

&lt;p&gt;Here’s how clear your endpoint code can look now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/users"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UserRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
   &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WithName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"CreateUser"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Less magic, more compile-time safety, and no more second-guessing your routes.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Smarter Entity Framework Core: Bulk Operations &amp;amp; Performance
&lt;/h2&gt;

&lt;p&gt;If you work with large datasets or ever had to write a manual loop just to update rows, this one’s for you. The new bulk operations like BulkUpdate and BulkDelete in EF Core have saved me from so much tedium and boosted performance in the process.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IsActive&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ExecuteUpdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastLogin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UtcNow&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now update or delete hundreds or thousands of rows with a single, efficient query. I wish this existed a few projects ago!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I’ll be honest: I don’t adopt every new .NET feature right away, but .NET 9 and 10 have a lot of compelling reasons to upgrade. Native AOT and observability alone are enough to simplify deployment and maintenance, and the C# and EF Core upgrades make writing and maintaining code more enjoyable. If you’re looking for ways to build faster, cleaner, and more reliable apps, these releases are well worth your attention.&lt;/p&gt;

&lt;p&gt;What new .NET feature are you most excited to try? Drop your thoughts below always happy to geek out about new tech!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>programming</category>
      <category>developer</category>
    </item>
    <item>
      <title>C# 12: Embracing the Quirks and Magic of Modern Programming</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Sun, 30 Jul 2023 14:56:41 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/c-12-embracing-the-quirks-and-magic-of-modern-programming-42ho</link>
      <guid>https://dev.to/iamprincejkc/c-12-embracing-the-quirks-and-magic-of-modern-programming-42ho</guid>
      <description>&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;Welcome to the exciting world of C# 12, where modern programming meets a touch of magic and humor! In this blog, we will explore the latest features introduced in C# 12, from primary constructors to code sorcery. So fasten your seatbelts, and let's dive into the quirky wonders of C#!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Constructors&lt;/strong&gt;: A Constructor Revolution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Constructors are the architects of object creation, and C# 12 brings a revolution with "Primary Constructors." Now, they are not just for record types; you can use them in any class or struct! Primary constructor parameters are in scope for the entire class, reducing boilerplate code. And remember to call the primary constructor from other constructors using "this()". Say goodbye to the mundane and welcome cleaner, more concise code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Primary constructor example&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Default Lambda Parameters&lt;/strong&gt;: Embracing Laziness!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lambdas are powerful, and C# 12 takes them a step further with "Default Lambda Parameters." Now, you can give your lambdas default values, just like regular methods. This lazy addition to lambdas simplifies your code without sacrificing functionality. Embrace the power of defaults and let your lambdas take it easy!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Default Lambda Parameters&lt;/span&gt;
&lt;span class="n"&gt;Func&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;addNumbers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      &lt;span class="c1"&gt;// result1 = 5 + 10 = 15&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// result2 = 5 + 7 = 12&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Alias Any Type&lt;/strong&gt;: The Language of Your Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Aliases just got a significant upgrade! With "Alias Any Type," you can create semantic aliases for any type, not just named ones. Tuple types, array types, pointers - anything you want! Give your code a unique language of its own and let your creativity flow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Alias Any Type&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;MyArray&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;  &lt;span class="c1"&gt;// Alias for int array&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Example&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;UseAlias&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;MyArray&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;MyArray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Inline Arrays&lt;/strong&gt;: Compact and Speedy!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inline arrays are here to supercharge your apps! They allow developers to create fixed-size arrays in struct types without the usual overhead. As a developer, you might not create them directly, but you'll enjoy their benefits through System.Span or System.ReadOnlySpan objects from runtime APIs. Get ready for compact and speedy performance!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompilerServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;InlineArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;Buffer&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;_element0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;buffer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Interceptors&lt;/strong&gt;: Unleashing Code Sorcery (Experimental)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Caution: Interceptors are experimental and not for production use.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Interceptors provide a glimpse into the world of code sorcery! This experimental feature allows you to declaratively substitute calls to interceptable methods with your custom logic at compile time. Think of it as a source generator's magic wand, modifying existing code rather than adding new code. But beware, with great power comes great responsibility!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Interceptable&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Interceptor method&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Interceptor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CustomAdd&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;InterceptedAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Interceptor activated!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;CustomAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;calculator&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Calculator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// The Interceptor will be invoked if enabled.&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Conclusion:
&lt;/h4&gt;

&lt;p&gt;Congratulations, adventurous programmers! You've now journeyed through the quirky world of C# 12, from primary constructors to code sorcery. Embrace these new features and let them infuse magic into your code. But remember, with great magic comes great responsibility! Enjoy exploring these innovative additions to C# and continue pushing the boundaries of your coding adventures. Happy coding, and may the quirks be with you!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Exploring the New Visual Studio Feature: .http Files</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Mon, 05 Jun 2023 15:16:04 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/exploring-the-new-visual-studio-feature-http-files-1i99</link>
      <guid>https://dev.to/iamprincejkc/exploring-the-new-visual-studio-feature-http-files-1i99</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visual Studio, the popular integrated development environment (IDE) by Microsoft, continually evolves to enhance developers' productivity and streamline their workflows. In the latest release, a new feature has been introduced: .http files. These files provide a convenient way to interact with HTTP APIs directly within Visual Studio. In this blog post, we will delve into the details of .http files, explore code examples in C#, discuss the system dynamic variables available, and highlight their similarity to the Visual Studio Code extension, "REST Client."&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Understanding .http Files:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;.HTTP files in Visual Studio act as a lightweight HTTP client, allowing developers to write and execute HTTP requests directly in the IDE. These files are inspired by the Visual Studio Code extension called "REST Client" and provide a similar experience within Visual Studio itself. They are designed to simplify the process of testing and debugging HTTP APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating an .http File:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create an .http file in Visual Studio, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right-click on your project or desired location in the Solution Explorer.&lt;/li&gt;
&lt;li&gt;Choose "Add" and then "New Item."&lt;/li&gt;
&lt;li&gt;Select "Text File" from the available templates and name it with the .http extension.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Writing HTTP Requests in C#:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's explore some code examples to demonstrate how to use .http files effectively in Visual Studio using C#. Assume we have an API endpoint at "&lt;a href="https://api.example.com/users" rel="noopener noreferrer"&gt;https://api.example.com/users&lt;/a&gt;" that returns a list of users in JSON format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sending a &lt;em&gt;GET&lt;/em&gt; Request:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//api.example.com/users&lt;/span&gt;

&lt;span class="n"&gt;HTTP&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="n"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sending a &lt;em&gt;POST&lt;/em&gt; Request:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;POST&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//api.example.com/users&lt;/span&gt;

&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"john.doe@example.com"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;System Dynamic Variables in .http Files:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visual Studio's .http files provide a set of system dynamic variables that you can utilize to enhance your HTTP requests. These variables simplify the process of including dynamic values in your requests, such as environment-specific URLs or authentication tokens.&lt;/p&gt;

&lt;p&gt;Here are the system dynamic variables available in .http files:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;{{guid}}&lt;/code&gt;: Generates a new GUID for each request.&lt;br&gt;
&lt;code&gt;{{randomInt}}&lt;/code&gt;: Generates a random integer for each request.&lt;br&gt;
&lt;code&gt;{{timestamp}}&lt;/code&gt;: Represents the current timestamp.&lt;br&gt;
&lt;code&gt;{{date}}&lt;/code&gt;: Represents the current date.&lt;br&gt;
&lt;code&gt;{{time}}&lt;/code&gt;: Represents the current time.&lt;br&gt;
&lt;code&gt;{{utcDate}}&lt;/code&gt;: Represents the current UTC date.&lt;br&gt;
&lt;code&gt;{{utcTime}}&lt;/code&gt;: Represents the current UTC time.&lt;br&gt;
&lt;code&gt;{{month}}&lt;/code&gt;: Represents the current month.&lt;br&gt;
&lt;code&gt;{{year}}&lt;/code&gt;: Represents the current year.&lt;br&gt;
&lt;code&gt;{{host}}&lt;/code&gt;: Represents the current host URL.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example using system dynamic variables:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;POST&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//api.example.com/users&lt;/span&gt;

&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"{{guid}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"john.doe@example.com"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="err"&gt;###&lt;/span&gt;

&lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//api.example.com/logs?timestamp={{timestamp}}&lt;/span&gt;

&lt;span class="err"&gt;###&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the introduction of .http files in Visual Studio, developers now have a convenient way to interact with HTTP APIs directly within their IDE. These files provide a familiar and intuitive syntax, making it easier to test and debug APIs without leaving the development environment. By utilizing system dynamic variables, developers can enhance their HTTP requests and streamline their workflows further. .http files in Visual Studio resemble the functionality of the "REST Client" extension in Visual Studio Code, providing a seamless experience across platforms.&lt;/p&gt;

&lt;p&gt;Start leveraging this powerful feature today and experience the productivity boost it offers!&lt;/p&gt;

&lt;p&gt;Happy coding with Visual Studio and .http files!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(Note: The code examples provided in this blog are for demonstration purposes only. Actual implementation may vary depending on the specific HTTP API and requirements.)&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>visualstudio</category>
      <category>csharp</category>
      <category>dotnet</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Pattern Matching Enhancements in C# 9: Exploring New Patterns</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Wed, 10 May 2023 15:07:45 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/pattern-matching-enhancements-in-c-9-exploring-new-patterns-114b</link>
      <guid>https://dev.to/iamprincejkc/pattern-matching-enhancements-in-c-9-exploring-new-patterns-114b</guid>
      <description>&lt;p&gt;As a C# developer, you're probably familiar with pattern matching. This feature allows you to test whether an expression matches a certain pattern and execute different code based on the result. In C# 9, Microsoft introduced several enhancements to pattern matching, including new patterns that make your code more concise and readable. In this blog post, I'll explore some of these new patterns and show you how to use them in your code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Logical Patterns
&lt;/h2&gt;

&lt;p&gt;The logical patterns &lt;em&gt;and&lt;/em&gt;, &lt;em&gt;or&lt;/em&gt;, and &lt;em&gt;not&lt;/em&gt; allow you to combine patterns into more complex expressions. For example, suppose you have a method that takes an object and performs different actions depending on its type and value. Using logical patterns, you can define a single &lt;em&gt;switch&lt;/em&gt; statement that handles all cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ProcessObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;or&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The string is '&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="s"&gt;"null"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The integer is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The boolean is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Unknown object"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the first case uses the logical pattern and to test whether the object is a non-empty string or null. It also uses the property pattern to check that the string has a length greater than zero. The second case uses the relational pattern &amp;gt;= to test whether the object is a non-negative integer. The third case uses a simple type pattern to test whether the object is a boolean. Finally, the default case handles all other cases.&lt;/p&gt;




&lt;h2&gt;
  
  
  Relational Patterns
&lt;/h2&gt;

&lt;p&gt;Relational patterns allow you to test whether an expression matches a certain relationship with a value. C# 9 introduces several new relational patterns, including &amp;gt;, &amp;lt;, &amp;gt;=, and &amp;lt;=. For example, suppose you have a method that takes a list of integers and prints the first number that is greater than 10:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintFirstGreaterThan10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The first number greater than 10 is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"There are no numbers greater than 10"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the is operator is used with the relational pattern &amp;gt;. This pattern tests whether the value of i is greater than 10. If so, it prints the number and returns from the method. Otherwise, it continues to the next number. If there are no numbers greater than 10, the method prints a message indicating that.&lt;/p&gt;




&lt;h2&gt;
  
  
  Type Patterns
&lt;/h2&gt;

&lt;p&gt;Type patterns allow you to test whether an expression is of a certain type and optionally bind it to a new variable. In C# 9, you can use the or pattern to test whether an expression is of one type or another. For example, suppose you have a method that takes an object and prints its type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;or&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"The type of the object is &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetType&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Unknown type"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the switch statement uses the or pattern to check whether the object is either a string or an int. If the object is a string or an int, the method prints its type. Otherwise, it prints "Unknown type".&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Pattern matching is a powerful feature in C# that allows developers to write concise and readable code. C# 9 introduces new patterns, such as logical patterns, relational patterns, and type patterns, which enable even more flexibility in handling different cases in code. By using these patterns, you can simplify your code and make it more expressive.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>programming</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Introducing C# 9.0's Record Datatype: Safe, Efficient, and Easy to Use</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Fri, 14 Apr 2023 10:55:27 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/introducing-c-90s-record-datatype-safe-efficient-and-easy-to-use-mnp</link>
      <guid>https://dev.to/iamprincejkc/introducing-c-90s-record-datatype-safe-efficient-and-easy-to-use-mnp</guid>
      <description>&lt;p&gt;C# 9.0 introduces a new datatype called &lt;code&gt;record&lt;/code&gt;, which is an immutable type that provides value-based equality. Records are ideal for representing data that is primarily for storage and retrieval. In this blog post, we'll explore the features and benefits of records, how to create them, and how they can be used in C# code through code examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features and Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;record&lt;/code&gt; datatype in C# has several features and benefits, including:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Immutability&lt;/em&gt;: Records are immutable, which means their values cannot be changed once they're created. This feature ensures records are safer to use because they can't be modified after they're created.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Value-Based Equality&lt;/em&gt;: Records provide value-based equality, which means that two records are equal if their values are equal. This feature makes it easy to compare records and determine if they're the same.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Built-In Deconstruction&lt;/em&gt;: Records have built-in deconstruction, which allows you to easily extract their values and assign them to variables. This feature makes it easy to work with records and use their values in your code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Concise Syntax&lt;/em&gt;: The syntax for creating records is concise, making it easy to create and use them in your code. This feature saves time when writing code and makes it easier to work with records.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Records&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a record in C#, you use the record keyword followed by the name of the record and its properties. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;record&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;Person&lt;/code&gt; record has three properties: &lt;code&gt;FirstName&lt;/code&gt;, &lt;code&gt;LastName&lt;/code&gt;, and &lt;code&gt;Age&lt;/code&gt;. These properties are used to store the person's first name, last name, and age.&lt;/p&gt;

&lt;p&gt;Using Records&lt;/p&gt;

&lt;p&gt;Records can be used in many ways in C# code. Here are some examples:&lt;/p&gt;

&lt;p&gt;Creating a list of records:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Jane"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we've created a list of Person records and added two records to the list. We've also specified the values for each property when we created the records.&lt;/p&gt;

&lt;p&gt;Using records as function return types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;record&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;FirstName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;LastName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="nf"&gt;GetPerson&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;GetPerson&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we've created a function that returns a Person record. We've then assigned the returned record to a variable, which can be used later in the code.&lt;/p&gt;

&lt;p&gt;Deconstructing records:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var person = new Person("John", "Doe", 30);
var (firstName, lastName, age) = person;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we've created a Person record and then deconstructed it to extract its values. The values are then assigned to variables, which can be used later in the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, the new record datatype in C# 9.0 is a powerful tool that can be used to store and retrieve data in a safe and efficient way. Its features, such as immutability, value-based equality, built-in deconstruction, and concise syntax, make it easy to use and save time when writing code. Records can help streamline code and improve its readability and maintainability. Whether you're working on a small project or a large-scale application, records can be a useful addition to your C# toolbox.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>programming</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Simplify Your Debugging Process with Visual Studio Group Breakpoints</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Thu, 06 Apr 2023 14:10:50 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/simplify-your-debugging-process-with-visual-studio-group-breakpoints-9ep</link>
      <guid>https://dev.to/iamprincejkc/simplify-your-debugging-process-with-visual-studio-group-breakpoints-9ep</guid>
      <description>&lt;p&gt;Visual Studio is a powerful integrated development environment that provides many useful tools for developers. One such tool is the Group Breakpoints feature, which allows you to set breakpoints for multiple lines of code at once. This can be especially useful when debugging complex applications that have many different code paths, or when debugging code that is spread out over multiple files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgshnisl0jqbz5m07y9sh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgshnisl0jqbz5m07y9sh.png" alt="Breakpoints" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use Group Breakpoints in Visual Studio, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the code file that you want to debug.&lt;/li&gt;
&lt;li&gt;Select the lines of code that you want to group together.&lt;/li&gt;
&lt;li&gt;Right-click on the selected lines of code and choose "Breakpoint" from the context menu.&lt;/li&gt;
&lt;li&gt;In the Breakpoint menu, select "Insert Group Breakpoint."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you have set a Group Breakpoint, Visual Studio will display a blue rectangle in the left margin of the code editor to indicate the location of the breakpoint. When the code reaches this breakpoint, the debugger will stop and allow you to inspect the state of the application.&lt;/p&gt;

&lt;p&gt;Group Breakpoints can be especially useful when debugging code that is spread out over multiple files. For example, if you have a complex function that is defined in multiple files, you can select all the lines of code that make up the function, right-click, and choose "Insert Group Breakpoint." This will create a single breakpoint that covers all the lines of code for the function, making it easier to debug the code and find any errors.&lt;/p&gt;

&lt;p&gt;Group Breakpoints can also be useful when debugging code that has multiple methods. Rather than setting individual breakpoints for each method, you can select all the lines of code for each method, right-click, and choose "Insert Group Breakpoint." This will create a single breakpoint that covers all the lines of code for each method, making it easier to debug multiple methods at once.&lt;/p&gt;

&lt;p&gt;To remove a Group Breakpoint, simply right-click on the blue rectangle in the left margin and choose "Delete Group Breakpoint" from the context menu.&lt;/p&gt;

&lt;p&gt;In conclusion, Group Breakpoints are a powerful tool for debugging complex applications in Visual Studio. They can help you save time and effort by allowing you to set breakpoints for multiple lines of code at once, making it easier to debug your code and find any errors. By following the steps outlined above, you can easily use Group Breakpoints to debug your own applications and streamline your development workflow.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>programming</category>
      <category>visualstudio</category>
    </item>
    <item>
      <title>A Better Way to Develop and Debug Applications</title>
      <dc:creator>JKC</dc:creator>
      <pubDate>Wed, 05 Apr 2023 15:42:44 +0000</pubDate>
      <link>https://dev.to/iamprincejkc/new-dev-tunnels-in-visual-studio-2j0p</link>
      <guid>https://dev.to/iamprincejkc/new-dev-tunnels-in-visual-studio-2j0p</guid>
      <description>&lt;h2&gt;
  
  
  New Dev Tunnels in Visual Studio
&lt;/h2&gt;

&lt;p&gt;Visual Studio is a popular integrated development environment (IDE) used by many developers to write and debug code. It has a wide range of features that can help streamline the development process, including a new feature called Dev Tunnels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Dev Tunnels?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dev Tunnels is a new feature in Visual Studio that enables developers to access their local development environment from remote devices, such as smartphones, tablets, or other computers. It creates a secure tunnel between the local machine and the remote device, allowing developers to test their applications in real-time without the need for additional hardware or software. Dev Tunnels work by using the ngrok service, which provides secure introspected tunnels to localhost.&lt;/p&gt;

&lt;p&gt;Dev Tunnels allow developers to easily expose a local development web server to the internet without deploying the code to a remote server. This can be useful for testing web applications or sharing a development site with others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do Dev Tunnels work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's how you can use the new Dev Tunnels feature in Visual Studio:&lt;/p&gt;

&lt;p&gt;Open Visual Studio and create a new web application project or open an existing one.&lt;/p&gt;

&lt;p&gt;Start the web application project by clicking the "Run" button or pressing "F5" on your keyboard.&lt;/p&gt;

&lt;p&gt;Once the web application is running, go to the "Debug" menu and select "Start New Dev Tunnel".&lt;/p&gt;

&lt;p&gt;In the "Start New Dev Tunnel" dialog box, select the web application project you want to expose and choose a port number to use.&lt;/p&gt;

&lt;p&gt;Click the "Start" button to create the tunnel.&lt;/p&gt;

&lt;p&gt;The Dev Tunnel will now be active, and you can access the local development server from any device with an internet connection by using the provided URL.&lt;/p&gt;

&lt;p&gt;For example, if you chose port 5000 and the provided URL is "&lt;a href="https://random-word-12345.loca.lt" rel="noopener noreferrer"&gt;https://random-word-12345.loca.lt&lt;/a&gt;", you can access your local development server by typing "&lt;a href="https://random-word-12345.loca.lt:5000" rel="noopener noreferrer"&gt;https://random-word-12345.loca.lt:5000&lt;/a&gt;" into your web browser.&lt;/p&gt;

&lt;p&gt;Using Dev Tunnels can save you time and hassle by allowing you to test and share your web application without deploying it to a remote server. Give it a try and see how it can help streamline your development process!&lt;/p&gt;

&lt;p&gt;In conclusion, Dev Tunnels is a new feature in Visual Studio that can help developers expose a local development web server to the internet without deploying the code to a remote server. It can be useful for testing web applications or sharing a development site with others. By following the steps above, you can easily use this new feature and improve your development workflow.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>webdev</category>
      <category>visualstudio</category>
    </item>
  </channel>
</rss>
