<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C# Archive - NDDTs Webdevelopment</title>
	<atom:link href="https://nddt-webdevelopment.de/category/c-sharp/feed/" rel="self" type="application/rss+xml" />
	<link>https://nddt-webdevelopment.de/category/c-sharp/</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 13 Jan 2023 04:19:18 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>What is new in C# 9</title>
		<link>https://nddt-webdevelopment.de/c-sharp/what-is-new-in-c-9/</link>
					<comments>https://nddt-webdevelopment.de/c-sharp/what-is-new-in-c-9/#respond</comments>
		
		<dc:creator><![CDATA[NDDT]]></dc:creator>
		<pubDate>Fri, 13 Jan 2023 04:19:16 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<guid isPermaLink="false">https://nddt-webdevelopment.de/?p=386</guid>

					<description><![CDATA[<p>C# 9 is the latest version of the C# programming language and it introduces several new features and improvements that make it easier to write more concise, expressive and maintainable code. Some of the notable new features in C# 9 include: C# 9 aims to simplify the language and reduce the amount of boilerplate code [&#8230;]</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/c-sharp/what-is-new-in-c-9/">What is new in C# 9</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><a href="https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9" target="_blank" rel="noreferrer noopener nofollow">C# 9 </a>is the latest version of the C# programming language and it introduces several new features and improvements that make it easier to write more concise, expressive and maintainable code. Some of the notable new features in C# 9 include:</p>



<ol class="wp-block-list">
<li>Records: C# 9 introduces a new type called records, which are lightweight classes that are designed for data modeling. Records automatically provide features such as immutability, equality and copy semantics.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy coderecord Person {
    public string FirstName { get; init; }
    public string LastName { get; init; }
}
</pre></div>


<ol class="wp-block-list" start="2">
<li>Init-only properties: C# 9 allows you to define properties that can only be set during object initialization, making it easy to create immutable types.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeclass Point {
    public int X { get; init; }
    public int Y { get; init; }
}
</pre></div>


<ol class="wp-block-list" start="3">
<li>Top-level statements: C# 9 allows you to use statements at the top level of a file, without requiring a class or method.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeusing System;

Console.WriteLine(&quot;Hello, World!&quot;);
</pre></div>


<ol class="wp-block-list" start="4">
<li>Target-typed new expressions: C# 9 allows you to use the &#8222;new&#8220; keyword without specifying the type of the object being created.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codevar point = new (1, 2);
</pre></div>


<ol class="wp-block-list" start="5">
<li>Improved pattern matching: C# 9 introduces several new pattern matching features, such as the &#8222;and&#8220; pattern, the &#8222;or&#8220; pattern, and the &#8222;not&#8220; pattern.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeif (shape is not Circle)
{
    // Do something
}
</pre></div>


<ol class="wp-block-list" start="6">
<li>Improved target-typed conditional expressions and null-coalescing expressions.</li>



<li>Support for asynchronous streams.</li>



<li>Improved support for immutable types with <code>init</code> setter.</li>
</ol>



<p class="wp-block-paragraph">C# 9 aims to simplify the language and reduce the amount of boilerplate code required, making it more productive and easier to work with. These new features should help to improve the developer experience while also increasing the expressiveness and maintainability of the code.</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/c-sharp/what-is-new-in-c-9/">What is new in C# 9</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nddt-webdevelopment.de/c-sharp/what-is-new-in-c-9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Performance Tipps in C#</title>
		<link>https://nddt-webdevelopment.de/c-sharp/performance-tipps-in-c/</link>
					<comments>https://nddt-webdevelopment.de/c-sharp/performance-tipps-in-c/#respond</comments>
		
		<dc:creator><![CDATA[NDDT]]></dc:creator>
		<pubDate>Fri, 13 Jan 2023 04:10:02 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<guid isPermaLink="false">https://nddt-webdevelopment.de/?p=378</guid>

					<description><![CDATA[<p>The C# programming language is widely used for building a variety of applications, from desktop software to web and mobile apps. As a high-level, object-oriented language, C# offers many features that make it easy to write efficient and maintainable code. However, as with any programming language, there are certain performance tips and tricks that can [&#8230;]</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/c-sharp/performance-tipps-in-c/">Performance Tipps in C#</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">The C# programming language is widely used for building a variety of applications, from desktop software to web and mobile apps. As a high-level, object-oriented language, C# offers many features that make it easy to write efficient and maintainable code. However, as with any programming language, there are certain performance tips and tricks that can help you write faster and more efficient code. The following list provides some of the most effective techniques for improving performance in C# applications. From using structs and avoiding reflection to working with asynchronous code and profiling your application, these tips can help you optimize your C# code and improve the overall performance of your application.</p>



<ol class="wp-block-list">
<li>Use the &#8222;using&#8220; statement when working with resources that implement IDisposable, such as file streams and database connections.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeusing (FileStream fs = new FileStream(&quot;file.txt&quot;, FileMode.Open))
{
    // Do something with the file stream
}
</pre></div>


<ol class="wp-block-list" start="2">
<li>Avoid using the &#8222;as&#8220; operator, as it can cause significant performance overhead. Instead, use the &#8222;is&#8220; operator to check the type of an object, and then cast it explicitly.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeobject obj = &quot;Hello&quot;;
if (obj is string)
{
    string str = (string)obj;
    Console.WriteLine(str);
}
</pre></div>


<ol class="wp-block-list" start="3">
<li>Use structs instead of classes when working with small, value-type data. Structs are stored on the stack and do not require memory allocation, while classes are stored on the heap and require memory allocation.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codestruct Point
{
    public int X;
    public int Y;
}
</pre></div>


<ol class="wp-block-list" start="4">
<li>Avoid using &#8222;string&#8220; for large amounts of text, use StringBuilder instead.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeStringBuilder sb = new StringBuilder();
for (int i = 0; i &lt; 100; i++)
{
    sb.Append(&quot;Hello&quot;);
}
string result = sb.ToString();
</pre></div>


<ol class="wp-block-list" start="5">
<li>Avoid using &#8222;foreach&#8220; loops when working with large collections. Instead, use &#8222;for&#8220; loops, as they offer better performance.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codefor (int i = 0; i &lt; list.Count; i++)
{
    Console.WriteLine(list&#x5B;i]);
}
</pre></div>


<ol class="wp-block-list" start="6">
<li>Use the &#8222;lock&#8220; statement when working with shared resources to avoid race conditions.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeprivate static object _lock = new object();

public static void Add(int value)
{
    lock (_lock)
    {
        _list.Add(value);
    }
}
</pre></div>


<ol class="wp-block-list" start="7">
<li>Avoid using reflection, as it can be slow. Instead, use pre-generated code or code generation tools.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeType t = typeof(MyClass);
MethodInfo method = t.GetMethod(&quot;MyMethod&quot;);
method.Invoke(null, null);
</pre></div>


<ol class="wp-block-list" start="8">
<li>Use the &#8222;unsafe&#8220; keyword when working with pointers and unmanaged code, as it allows for direct memory access and can greatly improve performance.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeunsafe static void Main()
{
    int* p = stackalloc int&#x5B;100];
    for (int i = 0; i &lt; 100; i++)
        p&#x5B;i] = i;
}
</pre></div>


<ol class="wp-block-list" start="9">
<li>Use the &#8222;async&#8220; and &#8222;await&#8220; keywords when working with asynchronous code to improve performance and responsiveness of your application.</li>
</ol>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeprivate async Task&lt;int&gt; GetDataAsync()
{
    HttpClient client = new HttpClient();
    var data = await client.GetStringAsync(&quot;https://www.example.com&quot;);
    return data.Length;
}
</pre></div>


<ol class="wp-block-list" start="10">
<li>Profile your application to identify performance bottlenecks and optimize the code accordingly.</li>
</ol>



<p class="wp-block-paragraph">Example: Using Visual Studio Profiler, you can profile your application to track the execution time of methods and identify where</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/c-sharp/performance-tipps-in-c/">Performance Tipps in C#</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nddt-webdevelopment.de/c-sharp/performance-tipps-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Regular Expressions in C#</title>
		<link>https://nddt-webdevelopment.de/regex/regular-expressions-in-c/</link>
					<comments>https://nddt-webdevelopment.de/regex/regular-expressions-in-c/#respond</comments>
		
		<dc:creator><![CDATA[NDDT]]></dc:creator>
		<pubDate>Wed, 11 Jan 2023 15:58:50 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Regex]]></category>
		<guid isPermaLink="false">https://nddt-webdevelopment.de/?p=365</guid>

					<description><![CDATA[<p>Regular expressions, also known as regex, are a powerful tool for manipulating text and data. They can be used to search for patterns in strings, replace certain parts of strings, and validate the format of strings. In C#, regular expressions are supported by the System.Text.RegularExpressions namespace, which provides a set of classes for working with [&#8230;]</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/regex/regular-expressions-in-c/">Regular Expressions in C#</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Regular expressions, also known as regex, are a powerful tool for manipulating text and data. They can be used to search for patterns in strings, replace certain parts of strings, and validate the format of strings. In C#, regular expressions are supported by the <code>System.Text.RegularExpressions</code> namespace, which provides a set of classes for working with regular expressions.</p>



<p class="wp-block-paragraph">One of the most commonly used classes in the <code>System.Text.RegularExpressions</code> namespace is the <code>Regex</code> class. This class allows you to create a regular expression object, which can be used to match strings against a specified pattern. For example, the following code creates a regular expression object that matches strings that contain the word &#8222;hello&#8220;:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codeRegex helloRegex = new Regex(&quot;hello&quot;);
</pre></div>


<p class="wp-block-paragraph">You can use the <code>IsMatch()</code> method of the <code>Regex</code> class to determine if a string matches the pattern specified by the regular expression. For example, the following code checks if the string &#8222;hello world&#8220; contains the word &#8222;hello&#8220;:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codestring input = &quot;hello world&quot;;
if (helloRegex.IsMatch(input))
{
    Console.WriteLine(&quot;The input contains the word 'hello'&quot;);
}
</pre></div>


<p class="wp-block-paragraph">In addition to matching patterns, regular expressions can also be used to perform replacements. The <code>Replace()</code> method of the <code>Regex</code> class can be used to replace all occurrences of a specified pattern with another string. For example, the following code replaces all occurrences of the word &#8222;hello&#8220; with &#8222;goodbye&#8220; in the input string:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codestring replaced = helloRegex.Replace(input, &quot;goodbye&quot;);
Console.WriteLine(replaced); // Outputs &quot;goodbye world&quot;
</pre></div>


<p class="wp-block-paragraph">You can use the <code>Split()</code> method of the <code>Regex</code> class to split a string into an array of substrings based on a specified pattern. For example, the following code splits the input string on spaces:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codestring&#x5B;] words = helloRegex.Split(input);
foreach (string word in words)
{
    Console.WriteLine(word);
}
// Outputs &quot;hello&quot; and &quot;world&quot;
</pre></div>


<p class="wp-block-paragraph">Regular expressions can also be used to validate the format of strings, such as email addresses, phone numbers, and so on. The <code>IsMatch()</code> method can be used to check whether a string matches a specific pattern, such as the pattern for an email address.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
Copy codestring email = &quot;user@example.com&quot;;
Regex emailRegex = new Regex(@&quot;^(&#x5B;\w\.\-]+)@(&#x5B;\w\-]+)((\.(\w){2,3})+)$&quot;);
if (emailRegex.IsMatch(email))
{
    Console.WriteLine(&quot;The email is valid.&quot;);
}
else
{
    Console.WriteLine(&quot;The email is not valid.&quot;);
}
</pre></div>


<p class="wp-block-paragraph">TLDR: Regular expressions are a powerful tool for working with text and data in C#. The <code>System.Text.RegularExpressions</code> namespace provides a set of classes for working with regular expressions, including the <code>Regex</code> class, which can be used to match, replace, and validate strings. Regular expressions can save lot of time, and can be very handy in situations where text parsing is needed.</p>
<p>Der Beitrag <a href="https://nddt-webdevelopment.de/regex/regular-expressions-in-c/">Regular Expressions in C#</a> erschien zuerst auf <a href="https://nddt-webdevelopment.de">NDDTs Webdevelopment</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nddt-webdevelopment.de/regex/regular-expressions-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 0/93 objects using Redis
Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Minified using Disk
Database Caching 5/35 queries in 0.006 seconds using Disk

Served from: nddt-webdevelopment.de @ 2026-05-29 03:05:30 by W3 Total Cache
-->