<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by eminy on Medium]]></title>
        <description><![CDATA[Stories by eminy on Medium]]></description>
        <link>https://medium.com/@eminy?source=rss-41575c567267------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2T7HeYNRPjEG-egX</url>
            <title>Stories by eminy on Medium</title>
            <link>https://medium.com/@eminy?source=rss-41575c567267------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 02:45:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eminy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[C# Arrays: A Fundamental Guide to Efficient Data Management]]></title>
            <link>https://medium.com/@eminy/c-arrays-a-fundamental-guide-to-efficient-data-management-f772741f127b?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/f772741f127b</guid>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[c-sharp-developer]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Sat, 14 Sep 2024 19:49:15 GMT</pubDate>
            <atom:updated>2024-09-14T19:49:15.800Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, and welcome back! In our last post, we unlocked the potential of C# keywords by exploring essential concepts for every developer. Today, we’re diving into another core aspect of C# programming: <strong>arrays</strong>. Arrays are a foundational tool that allow you to store and manipulate collections of data in a structured and efficient manner. Whether you’re dealing with integers, strings, or more complex data types, mastering arrays will help you manage information more effectively and write cleaner, optimized code.</p><p>In this guide, we’ll walk through the key concepts of arrays, including their initialization, usage, and powerful built-in methods. By the end of this article, you’ll have a strong understanding of how arrays can elevate your C# projects. Let’s dive in and explore the versatility of arrays in C#!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*GPKtzKxOrNfCtPtBt3gt0A.png" /></figure><h4>Arrays</h4><p>Arrays are data structures that allow us to store multiple values of the same type under a single variable. They are one of the fundamental data structures in procedural programming, managing data sets by holding a specific area in memory.</p><p>When we create an array, we can perform batch operations on the elements within it. Arrays also form the foundation of collections and are the building blocks of more advanced data structures.</p><p>Arrays are reference types, meaning they are object-based structures and are essentially classes. They are stored in the HEAP section of RAM. Any array can contain only one type of data, and this data is arranged sequentially.</p><h3>Key Points:</h3><ul><li>An array contains only one data type, whether it’s a value type or a reference type. However, there cannot be a mix of types.</li><li>Elements added to an array are stored sequentially.</li><li>Each element added to an array is indexed, starting from 0 for the first element, and going up to N-1 based on the array’s size.</li></ul><h3>Defining an Array:</h3><p>To define an array, we use []. For example:</p><pre>type[] name = new type[n];</pre><p>In this definition, type specifies the array type, name is the array&#39;s name, and n indicates the length of the array. Example:</p><pre>int[] ages = new int[5];  // An integer array with 5 elements<br>string[] names = new string[3];  // A string array with 3 elements</pre><p>Here, the ages array holds 5 integer values, while the names array holds 3 string values.</p><h3>Array Limitations:</h3><p>Arrays are fixed in size once they are created. After an array is defined, the number of elements cannot be changed, which means the memory allocated for unused elements remains fixed. This limitation can lead to wasted memory space for unused elements.</p><p>When arrays are allocated, default values corresponding to their type are assigned to the respective fields. As a result of such an assignment, the memory allocation in RAM will be as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*UhpHna0mpFbU-fSWmiB1GA.png" /><figcaption>default</figcaption></figure><h3>Assigning and Accessing Values in Arrays:</h3><p>When working with arrays, we access elements using their index number:</p><pre>ages[0] = 25;  // Assigns 25 to the 0th index</pre><p>To access an element in an array, we again use the index:</p><pre>Console.WriteLine(ages[0]);  // Prints the value of the 0th index: 25</pre><p>If you try to operate on an index beyond the array size, you’ll encounter an IndexOutOfRangeException error. Therefore, it&#39;s important to be mindful of the array&#39;s boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*gxEXy3srV0TlwJhLjuA2Xw.png" /><figcaption>runtime error</figcaption></figure><h3>Array Loops:</h3><p>Arrays are often used with loops. Below, you can see how to traverse an array using both a for loop and a do-while loop:</p><pre>for (int i = 0; i &lt; ages.Length; i++)<br>{<br>    Console.WriteLine(ages[i]);<br>}</pre><p>Here, the Length property returns the length of the array, and each element is printed to the screen sequentially.</p><h3>Variations of Array Definitions:</h3><p>There are several different ways to create arrays:</p><blockquote><strong><em>Variation 1</em></strong><em>:</em></blockquote><pre>int[] numbers = new int[5];  // An integer array with 5 elements (defaults to 0)<br>numbers[0] = 10;<br>numbers[1] = 20;</pre><blockquote><strong>Variation 2</strong>:</blockquote><pre>int[] ages = {12, 34, 54, 67};<br>string[] names = {&quot;Alex&quot;, &quot;John&quot;, &quot;Emily&quot;};</pre><blockquote><strong>Variation 3</strong>:</blockquote><pre>int[] ages = new int[] {12, 34, 54, 67};<br>string[] names = new string[] {&quot;Alex&quot;, &quot;John&quot;, &quot;Emily&quot;};</pre><blockquote><strong>Variation 4</strong>:</blockquote><pre>string[] names = new string[3]{&quot;Alex&quot;, &quot;John&quot;, &quot;Emily&quot;};</pre><blockquote><strong>Variation 5</strong>:</blockquote><pre>int[] numbers = new int[] {1, 2, 3, 4, 5};  // An integer array with 5 elements<br>var numbers = new[] {12, 34, 54, 67};</pre><h3>The Array Class and Its Methods:</h3><p>Arrays are derived from the Array class, which provides various methods for operating on arrays.</p><p><strong>Clear</strong>: The Array.Clear method is used to reset the values of elements in a specified array to their default values without changing the size of the array.</p><pre>Array.Clear(array, startIndex, count);</pre><p><em>Example:</em></p><pre>int[] numbers = {1, 2, 3, 4, 5};<br>// Resets 3 elements starting from the second element<br>Array.Clear(numbers, 1, 3);<br>foreach (int number in numbers)<br>{<br>    Console.WriteLine(number);<br>}</pre><p>In this example, the array initially contains {1, 2, 3, 4, 5}, but after Array.Clear, the result will be:</p><pre>1 0 0 0 5</pre><p><strong>Copy</strong>: The Array.Copy method is used to copy elements from one array to another.</p><pre>Array.Copy(sourceArray, targetArray, count);</pre><p><em>Example:</em></p><pre>int[] sourceArray = {1, 2, 3, 4, 5};<br>int[] targetArray = new int[5];<br>Array.Copy(sourceArray, targetArray, sourceArray.Length);<br>foreach (int number in targetArray)<br>{<br>    Console.WriteLine(number);<br>}</pre><p><em>Output:</em></p><pre>1<br>2<br>3<br>4<br>5</pre><p><strong>Array.IndexOf</strong>: The IndexOf method returns the index of the first occurrence of a specified element within an array. If the element is not found, it returns -1.</p><pre>int index = Array.IndexOf(array, element);</pre><p><em>Example:</em></p><pre>int[] numbers = {10, 20, 30, 40, 50};<br>int index = Array.IndexOf(numbers, 30);  // Index of 30 is 2<br>Console.WriteLine(index);  // Output: 2</pre><p>If the element is not found:</p><pre>int indexNotFound = Array.IndexOf(numbers, 100);  // 100 is not found, returns -1<br>Console.WriteLine(indexNotFound);  // Output: -1</pre><p><strong>Array.Reverse</strong>: The Reverse method reverses the elements of an array.</p><pre>Array.Reverse(array);</pre><p><em>Example:</em></p><pre>int[] numbers = {1, 2, 3, 4, 5};<br>Array.Reverse(numbers);<br>foreach (int number in numbers)<br>{<br>    Console.WriteLine(number);<br>}</pre><p><em>Output:</em></p><pre>5<br>4<br>3<br>2<br>1</pre><p><strong>Array.Sort</strong>: The Sort method sorts the elements of an array in ascending order.</p><pre>Array.Sort(array);</pre><p><em>Example:</em></p><pre>int[] numbers = {50, 10, 40, 20, 30};<br>Array.Sort(numbers);<br>foreach (int number in numbers)<br>{<br>    Console.WriteLine(number);<br>}</pre><p><em>Output:</em></p><pre>10<br>20<br>30<br>40<br>50</pre><h3>Multidimensional Arrays:</h3><p>Multidimensional arrays are often used in game programming or advanced statistical work. In multidimensional arrays, the number of commas in the indexer plus one gives the array’s dimension:</p><pre>type[,] -&gt; 2-dimensional array<br>type[,,] -&gt; 3-dimensional array</pre><p><em>Example:</em></p><pre>int[,] numbers = new int[3, 5];  // A 2D array</pre><p><strong>Assigning Values in Multidimensional Arrays</strong>:</p><pre>int[,] numbers = new int[3, 4];<br>numbers[0, 0] = 2;<br>numbers[1, 2] = 5;<br>numbers[2, 0] = 6;</pre><p><strong>Reading Values from Multidimensional Arrays</strong>:</p><pre>Console.WriteLine(numbers[0, 1]);</pre><p><strong>Printing Multidimensional Arrays with Nested Loops</strong>:</p><pre>int[,] matrix = new int[3, 3]<br>{<br>    { 1, 2, 3 },  // Row 1<br>    { 4, 5, 6 },  // Row 2<br>    { 7, 8, 9 }   // Row 3<br>};<br>for (int i = 0; i &lt; matrix.GetLength(0); i++)  // Row count<br>{<br>    for (int j = 0; j &lt; matrix.GetLength(1); j++)  // Column count<br>    {<br>        Console.Write(matrix[i, j] + &quot; &quot;);<br>    }<br>    Console.WriteLine(&quot;&quot;);  // New line after each row<br>}</pre><p>Using GetLength, you can determine the number of elements in a specific dimension.</p><p><strong><em>Conclusion:</em></strong></p><p><em>Arrays are an essential data structure that every C# developer should master. In this article, we’ve covered the basics of arrays, from single-dimensional to multi-dimensional arrays, as well as built-in methods that simplify data manipulation. By understanding the structure and capabilities of arrays, you can write cleaner, more efficient code and handle large datasets with ease. Keep practicing, and soon you’ll find arrays becoming a natural part of your programming toolkit. Stay tuned for more insights on C# programming, and happy coding!✨</em></p><p><strong><em>Acknowledgments:</em></strong></p><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f772741f127b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of C# Keywords: Essential Concepts for Every Developer]]></title>
            <link>https://medium.com/@eminy/unlocking-the-power-of-c-keywords-essential-concepts-for-every-developer-bcdd6553f7b0?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcdd6553f7b0</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[c-sharp-developer]]></category>
            <category><![CDATA[keywords]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 22:42:04 GMT</pubDate>
            <atom:updated>2024-08-11T22:42:04.073Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to this in-depth exploration of C# programming keywords! Understanding how these fundamental elements work is crucial for anyone looking to deepen their C# coding skills. Keywords are the building blocks that define the structure and behavior of your C# code. By grasping the nuances of different keywords, you can write more efficient, readable, and powerful C# programs. In this article, we’ll break down the types of C# keywords, their roles in programming, and how they influence code logic. Ready to enhance your understanding of these essential C# programming components? Let’s dive in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMUou-aUG5--mMRXO2F8NQ.png" /></figure><h4><strong>Keywords: The Building Blocks of Programming Languages</strong></h4><p>Keywords are considered the most fundamental elements of a programming language. These are predefined words with special significance to the compiler. In essence, they are predefined by the compiler, serve a specific purpose, and are governed by strict rules regarding where and how they can be utilized within the code.</p><h4><strong>Keywords vs. Operators: Understanding the Difference</strong></h4><p>A common question that arises is, “What distinguishes keywords from operators?” While operators are primarily used to perform specific actions or operations, keywords encompass broader concepts. It’s important to note that all operators are technically keywords, but not all keywords serve as operators.</p><h4><strong>Categories of Keywords</strong></h4><p>Keywords can be broadly categorized into two types: concept-based and non-concept-based keywords.</p><h3>Concept-Based Keywords</h3><p>Concept-based keywords are not typically used in isolation; they are integral parts of larger structures within the code. For example, the keyword while may not convey much on its own, but when used as while() {}, it gains significance as part of a loop structure. Similarly, for is another keyword that, while meaningless by itself, becomes functional when used in a construct like for(int i = 0; i &lt; 10; i++) {}.</p><p>The key to effectively using concept-based keywords lies in understanding the broader concept or structure to which they belong.</p><h3>Non-Concept-Based Keywords</h3><p>These keywords are meaningful on their own and do not require a broader context to make sense. Examples include return, break, continue, and goto.</p><h3>Control Flow Keywords: Navigating Code Execution</h3><p>Control flow keywords allow developers to manipulate the flow of code — stopping it, skipping certain sections, exiting loops, or terminating methods entirely. These keywords enable more effective maneuvering within the code. There are four primary control flow keywords:</p><ul><li>break</li><li>continue</li><li>return</li><li>goto</li></ul><h3>The break Keyword</h3><p>The break command is used specifically in two scenarios:</p><ul><li>Switch-case statements</li><li>Loops</li></ul><p>This keyword is employed exclusively within these structures to exit or terminate them.</p><p><strong><em>Example 1:</em></strong></p><pre>switch (10)<br>{<br>    case 5:<br>        //operations<br>        break;<br>    case 10:<br>        //operations<br>        break;<br>    case 15:<br>        //operations<br>        break;<br>}</pre><p>In this example, after entering the case 10 block and executing the necessary operations, the break command exits the switch-case structure without evaluating any further cases.</p><p><strong><em>Example 2:</em></strong></p><pre>while (true)<br>{<br>    break;<br>}<br><br>for (int i = 0; i &lt; 10; i++)<br>{<br>    break;<br>}<br><br>do<br>{<br>    break;<br>} while (true);</pre><p>The break command can also be used within loops.</p><p><strong>Important Note:</strong> The break command can also be utilized in a foreach loop.</p><p><strong><em>Example:</em></strong></p><pre>foreach (var item in new[] { &quot; &quot; })<br>{<br>    break;<br>}</pre><p>Typically, the break command is not used within if-else or try-catch structures; however, if these structures are defined within a loop, the break command can be used within them.</p><p><strong><em>Example:</em></strong></p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br>    if (i == 5)<br>    {<br>        Console.WriteLine(&quot;Output&quot;);<br>        break;<br>    }<br>    Console.WriteLine(i);<br>}</pre><p>In this example, the loop will print numbers from 1 to 10, but if i equals 5, the loop will terminate due to the breakstatement within the if block.</p><p><strong><em>Example: Creating a program that sums an unlimited number of integers until the user enters the letter ‘t’, then displays the result.</em></strong></p><pre>int result = 0;<br>while (true)<br>{<br>    Console.WriteLine(&quot;Enter a number: &quot;);<br>    string input = Console.ReadLine();<br>    if (input == &quot;t&quot;)<br>    {<br>        Console.WriteLine(&quot;You entered &#39;t&#39;. The process has ended.&quot;);<br>        break;<br>    }<br>    else<br>    {<br>        result += int.Parse(input);<br>        Console.WriteLine(result);<br>    }<br>}</pre><h3>The continue Keyword</h3><p>The continue keyword is used exclusively within loops and allows the loop to skip the current iteration and proceed to the next one.</p><p><strong><em>Example: Printing even numbers between 0 and 10.</em></strong></p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br>    if (i % 2 != 0)<br>        continue;<br>    Console.WriteLine(i);<br>}</pre><p>In this example, if the value of i is not divisible by 2, the loop skips the iteration and proceeds to the next one.</p><p><strong><em>Example: Printing Numbers Between 1 and 1000 That Are Not Multiples of 7</em></strong></p><pre>for (int i = 1; i &lt; 1000; i++)<br>{<br>    if (i % 7 == 0)<br>        continue;<br>    Console.WriteLine(i);<br>}</pre><h3>The return Keyword</h3><p>The return keyword can be used at any point within a method. It serves two main functions:</p><ol><li>It terminates the method in which it is called.</li><li>It returns a value from the method. The concept of returning values will be covered in more detail in future discussions on methods.</li></ol><p>Once a return statement is executed, the method ends immediately, and any subsequent commands will not be executed.</p><p><strong><em>Example: Creating a Program That Runs Until the User Presses ‘c’</em></strong></p><pre>while (true)<br>{<br>    Console.WriteLine(&quot;Enter a value: &quot;);<br>    char letter = Console.ReadKey().KeyChar;<br>    if (letter == &#39;c&#39;)<br>    {<br>        Console.WriteLine(&quot;The program has ended&quot;);<br>        return;<br>    }<br>    Console.WriteLine(&quot;The program is running&quot;);<br>}</pre><p><strong>Note:</strong> If you want to check the key press immediately and retrieve the value without pressing Enter, use Console.ReadKey(). The KeyChar property will retrieve the incoming value as a char type.</p><h3>The goto Keyword</h3><p>The goto keyword is a control flow keyword that disrupts the normal sequence of code execution, allowing the flow to be redirected to another point in the code. While implicitly used within switch-case structures, goto can be employed anywhere within a method.</p><p><strong><em>Syntax:</em></strong></p><pre>a:<br>// Code<br>goto a;</pre><p>First, a reference point (label) is defined. Then, the goto keyword redirects the code flow to the defined reference.</p><p>Traditional developers generally discourage the use of the goto keyword, citing potential technical drawbacks. Performance tests indicate a slight loss and slowdown, making its usage costly in terms of efficiency.</p><p><strong><em>Example:</em></strong></p><pre>switch (10)<br>{<br>    case 5:<br>        Console.WriteLine(&quot;The number is 5&quot;);<br>        break;<br>    case 10:<br>        goto case 5;<br>}</pre><p><strong><em>Example 2:</em></strong></p><pre>label:<br>Console.WriteLine(&quot;a&quot;);<br>goto label;</pre><p>In this example, the program enters an infinite loop.</p><p><strong><em>Important Note:</em></strong> While the goto keyword can redirect the flow downward within a switch-case structure, it cannot redirect to code that is below the goto statement outside of this context.</p><p><strong><em>Example:</em></strong> <strong><em>Counting from 1 to 100</em></strong></p><pre>int i = 1;<br>x:<br>Console.WriteLine(i++);<br>if (i &lt;= 100)<br>    goto x;</pre><p><strong><em>Conclusion</em></strong></p><p><em>✨ Mastering programming keywords is a key step in writing efficient and effective code. In this article, we’ve covered the different types of keywords, from those that structure your code to those that control its flow. Understanding how and when to use these keywords can significantly improve your programming skills and lead to more robust and maintainable code. Keep practicing and experimenting with different scenarios to solidify your knowledge. Stay tuned for more insights and tips as you continue your journey in software development. Happy coding! ✨</em></p><p><strong><em>Acknowledgments:</em></strong></p><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcdd6553f7b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Smarter, Not Harder: Harnessing the Full Power of C# Loops]]></title>
            <link>https://medium.com/@eminy/code-smarter-not-harder-harnessing-the-full-power-of-c-loops-4983274bb339?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/4983274bb339</guid>
            <category><![CDATA[c-sharp-developer]]></category>
            <category><![CDATA[csharp-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[loops-in-c-sharp]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Fri, 09 Aug 2024 16:35:56 GMT</pubDate>
            <atom:updated>2024-08-09T16:36:44.278Z</atom:updated>
            <content:encoded><![CDATA[<p>In the journey of learning software development, understanding the fundamental concepts is key to becoming an effective programmer. One such essential concept is loops — structures that allow us to automate repetitive tasks, ensuring efficiency and accuracy in our code. Whether you’re iterating through a collection of data, summing numbers, or searching for a specific value, loops are your go-to tool. In this article, we’ll explore the different types of loops in programming, their syntax, and how to choose the right one for your specific scenario. Ready to enhance your coding skills by mastering loops? Let’s dive in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e4FclXr5rO0gfdpDD519yA.jpeg" /></figure><p><strong>Loops</strong> are fundamental building blocks of software development processes. They are structures that allow specific pieces of code, constructs, or programs to be repeated a certain number of times as long as a particular condition or combination is met. The loop continues to execute its internal code as long as the condition or combination is satisfied. Generally, there are three main types of loops:</p><ul><li><strong>For Loop</strong></li><li><strong>While Loop</strong></li><li><strong>Do-While Loop</strong></li></ul><p>Instead of asking, &quot;Which loop should be used where?&quot; a better question would be, &quot;Which loop best fits the current scenario?&quot; Since all these loops operate based on a specific combination of conditions, any of them can be used depending on the scenario&#39;s requirements.</p><h3>For Loop</h3><p>The <strong>for loop</strong> is one of the looping structures in programming and is typically used in sequential processes.</p><p><strong><em>Syntax:</em></strong></p><pre>for (x; y; z)<br>{<br><br>}</pre><ul><li><strong>x:</strong> Usually the initial value or the first assignment. Sequential algorithms generally require an initial value, which can be defined here. This assignment is optional; however, if defined, a value must be assigned.</li><li><strong>y:</strong> The condition. Any condition or expression can be defined here, but it generally checks the status of the variable defined as the initial value. The loop will execute as long as this condition is true.</li><li><strong>z:</strong> This is usually used to increase or decrease the initial value. Any operation can be performed on the variable, but typically it’s used for incrementing or decrementing based on the need. This field is also optional.</li><li><strong>{ }</strong>: The code block within these curly braces will be executed as long as the condition is true.</li></ul><p><strong><em>Example:</em></strong></p><pre>for (int number = 1; number &lt; 10; number++)<br>{<br>    Console.WriteLine(number + &quot; is less than 10&quot;);<br>}</pre><p>If the initial value is defined within the parentheses of the for loop, a value must be assigned.</p><p>The flow will first enter the initial value assignment part. If there is a variable declaration, it will define the relevant variable. Then, it will evaluate the condition. If the condition is true, the loop will execute. If false, it will exit the loop. If the condition is true, the loop will move to the increment/decrement part and apply the arithmetic operation to the variable. After modifying the variable, it will check the condition again. If true, the loop will repeat; if false, it will exit. This process will continue until the condition becomes false, triggering the loop to stop.</p><p><strong><em>Example:</em></strong></p><p>Let’s print the name “John” on the screen 10 times:</p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br>    Console.WriteLine(&quot;John&quot;);<br>}</pre><p>This can be done in various ways; for example:</p><pre>for (int i = 0; i &lt; 50; i += 5)<br>{<br>    Console.WriteLine(&quot;John&quot;);<br>}</pre><p>This also produces the same result. Additionally, incrementing is not mandatory. Consider the following example:</p><pre>for (int i = 10; i &gt; 0; i--)<br>{<br>    Console.WriteLine(&quot;John&quot;);<br>}</pre><p>This will also yield the same result.</p><p>If the loop involves incrementing, the variable is evaluated using the &lt; (less than) operator. If it involves decrementing, the variable is evaluated using the &gt; (greater than) operator.</p><p><strong><em>Example:</em></strong></p><p>Let’s sum the even numbers between 1 and 40 and display the result:</p><pre>int result = 0;<br>for (int i = 1; i &lt;= 40; i++)<br>{<br>    if (i % 2 == 0)<br>    {<br>        result += i;<br>    }<br>}<br>Console.WriteLine(&quot;Result: &quot; + result);</pre><p><strong><em>Example 2:</em></strong></p><p>Let’s write a program to find the factorial of a number entered from the keyboard:</p><p><strong><em>First Solution:</em></strong></p><pre>Console.WriteLine(&quot;Enter a number: &quot;);<br>int number = int.Parse(Console.ReadLine());<br>int result = 1;<br><br>for (int i = 1; i &lt;= number; i++)<br>{<br>    result *= i;<br>}<br>Console.WriteLine(result);</pre><p><strong><em>Second Solution:</em></strong></p><pre>Console.WriteLine(&quot;Enter a number: &quot;);<br>int number = int.Parse(Console.ReadLine());<br>int result = 1;<br><br>for (int i = number; i &gt; 0; i--)<br>{<br>    result *= i;<br>}<br>Console.WriteLine(result);</pre><h3><strong>While Loop</strong></h3><p>The <strong>while loop</strong> is a condition-based loop. It executes as long as the condition is true. It is simpler and more primitive compared to the <strong>for loop</strong> and is one of the earliest loop structures designed in programming. It is often used in infinite loops or in situations where the process duration is unknown, but it can be used wherever needed.</p><p><strong><em>Syntax:</em></strong></p><pre>while (condition)<br>{<br><br>}</pre><h4>Difference Between While and For Loop:</h4><p>To function like a <strong>for loop</strong>, the combination in a <strong>while loop</strong> must be manually created.</p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br>    Console.WriteLine(&quot;John&quot;);<br>}<br><br>int i = 0;<br>while (i &lt; 10)<br>{<br>    Console.WriteLine(&quot;John&quot;);<br>    i++;<br>}</pre><p>Both will print “John” to the screen 10 times.</p><p><strong><em>Example:</em></strong></p><p>Write a program that prints “Hello World” 10 times on the screen.</p><pre>int i = 1;<br>while (i &lt;= 10)<br>{<br>    Console.WriteLine(&quot;Hello World&quot;);<br>    i++;<br>}</pre><p><strong><em>Example:</em></strong></p><p>Write a program that sums the odd numbers between 0 and 100 and displays the result:</p><pre>int i = 0, total = 0;<br>while (i &lt;= 100)<br>{<br>    if (i % 2 == 1)<br>    {<br>        total += i;<br>    }<br>    i++;<br>}<br>Console.WriteLine(total);</pre><p><strong><em>Example:</em></strong></p><p>Find the factorial of a number entered from the keyboard:</p><pre>Console.Write(&quot;Enter a number to find its factorial: &quot;);<br>int number = int.Parse(Console.ReadLine());<br>int result = 1, i = 1;<br><br>while (i &lt;= number)<br>{<br>    result *= i;<br>    i++;<br>}<br>Console.WriteLine(result);</pre><h3><strong>Do-While Loop</strong></h3><p>The <strong>do-while loop</strong> is very similar to the <strong>while loop</strong>. Both loops execute as long as the condition is true. However, the key difference is that in a <strong>while loop</strong>, the condition is checked before executing the code, whereas in a <strong>do-while loop</strong>, the code is executed first, and then the condition is checked.</p><p>In a <strong>while loop</strong>, the loop will only start if the condition is true; if false, it will never start. However, in a <strong>do-while loop</strong>, the loop will execute at least once, regardless of whether the condition is true or false.</p><p><strong><em>Syntax:</em></strong></p><pre>do<br>{<br>    // Code<br>}<br>while (condition);</pre><p><strong><em>Example:</em></strong></p><pre>int i = 0;<br>do<br>{<br>    Console.WriteLine(i);<br>}<br>while (i &gt; 0);</pre><p>In this example, the loop prints the initial value (0) to the screen and then checks the condition. Since the condition is false, the loop does not repeat.</p><h3>Is Foreach a Loop?</h3><p>Loops are constructs that work with a specific combination and perform periodic operations based on a condition. However, <strong>foreach</strong> is not considered a loop; it is more accurately described as an iteration. In the context of iteration, there is no logic of combination or condition. Iteration refers to the process of traversing or retrieving data over a data set. I will explain this topic in more detail in my future articles.</p><p><strong><em>Conclusion:</em></strong></p><p><em>Mastering loops is crucial for writing efficient and effective code. Throughout this article, we’ve explored the various types of loops, from the straightforward </em><strong><em>for loop</em></strong><em> to the more condition-focused </em><strong><em>while</em></strong><em> and </em><strong><em>do-while loops</em></strong><em>. Understanding when and how to use these loops can greatly enhance the performance and readability of your programs. Keep practicing with different scenarios, and you’ll soon find yourself navigating loops with ease. For more insights into programming fundamentals, be sure to follow me as I continue sharing valuable tips and tricks on your coding journey. Happy coding! ✨</em></p><p><strong><em>Acknowledgments:</em></strong></p><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4983274bb339" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Error Handling Mechanisms in Software Development]]></title>
            <link>https://medium.com/@eminy/mastering-error-handling-mechanisms-in-software-development-21729da60827?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/21729da60827</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[c-sharp-development]]></category>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Fri, 09 Aug 2024 07:16:57 GMT</pubDate>
            <atom:updated>2024-08-09T07:16:57.496Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of software development, things don’t always go as planned. Errors encountered while coding can be one of the biggest headaches for developers. However, having the right strategies to effectively manage these errors and preserve user experience is crucial. In this article, we will explore the different types of errors encountered during the software development process, how to identify them, and how to manage them effectively. Ready to dive into the world of error management and make your projects more robust and reliable? Let’s get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bdRKPftjh2tPYhBOHIAwBQ.png" /></figure><p>Encountering various errors is an inevitable aspect of software development. These errors are intrinsic to the nature of creating and maintaining software. In this article, we will delve into how to handle these errors using effective error handling mechanisms. We will discuss three primary types of errors:</p><ul><li>Compiler Errors</li><li>Runtime Errors</li><li>Logical Errors</li></ul><p>We will explore how to control and manage these errors throughout the software development process and discuss the best practices and approaches for addressing each type.</p><h3>Compiler Errors</h3><p>Compiler errors are syntax errors that occur when the code does not conform to the rules of the programming language. Modern integrated development environments (IDEs) and advanced editors can often detect these errors even before compilation. The compiler reports the specific line where the error is located, making these errors the easiest to identify and resolve.</p><p>For instance, consider the following example where ‘static’ is incorrectly written as ‘stat_c’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*w7I-oK2oEOjgGXAbaR4ISg.png" /></figure><p>In this case, the compiler will immediately flag ‘stat_c’ as an error.</p><p>Another common example is variable names starting with digits, which will also be flagged by the compiler:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*hiIOQxvhjKk2ikq62U-wXA.png" /><figcaption>Error: Variable names cannot start with a digit</figcaption></figure><p>In previous articles, I have discussed the rules of C#. Ignoring these rules will inevitably result in compiler errors, with the editor underlining the erroneous lines to indicate the issues.</p><h3>Runtime Errors</h3><p>When there are no syntax errors, the code’s semantics are flawless, and the code compiles successfully but encounters issues during execution, this is referred to as a runtime error.</p><p>Runtime errors occur when software encounters unexpected conditions while running, causing the operating system to terminate the program. These errors can directly impact users during the program’s operation, which is undesirable for any developer. Therefore, it’s crucial to manage potential runtime errors effectively.</p><p>Runtime errors typically provide predefined messages within the architecture used. If the error is not predefined in the architecture, the operating system’s language will be used, resulting in more complex explanations. Ideally, runtime errors should be detected and handled by the developer in a more understandable manner before reaching the user.</p><p>Effective management of runtime errors involves thorough testing during the development process to identify and address these errors. Here’s how to manage runtime errors:</p><h4>Key Points:</h4><p>Error handling mechanisms exist to catch runtime errors without the user noticing and to manipulate the related errors.</p><p><strong><em>Common Runtime Error Scenarios:</em></strong></p><ul><li>Attempting to open, write to, or read from a non-existent file</li><li>Performing operations on non-existent values</li><li>Working with incompatible formats</li><li>Database connection failures</li></ul><p><strong><em>Example:</em></strong></p><p>If a string value is entered instead of an integer for the second number, and converting the string to an integer is not possible, a runtime error will occur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*3QGV0NXml6M0dc7tQVph5w.png" /></figure><p>To handle potential runtime errors, the try-catch structure is used, allowing us to manipulate and control these errors.</p><h3>Handling Runtime Errors with Try-Catch</h3><p>The try-catch structure allows us to manipulate and handle potential runtime errors. It ensures that errors are managed without disrupting the user experience.</p><p><strong><em>Syntax:</em></strong></p><pre>try<br>{<br>    // Code that might throw runtime errors<br>}<br>catch (Exception ex)<br>{<br>    // Code to handle the error<br>}</pre><p>The try-catch structure is a critical component in error handling, designed to manage potential runtime errors without impacting the user experience. This structure not only ensures that users are shielded from unexpected issues but also provides valuable insights into the nature of the errors, allowing for comprehensive logging and troubleshooting.</p><p><strong><em>Objectives:</em></strong></p><ul><li><strong>User Experience:</strong> To ensure that users are not exposed to runtime errors.</li><li><strong>Error Communication:</strong> To provide users with clear information about the cause of the error.</li><li><strong>Application Continuity:</strong> Operating systems typically terminate applications when they encounter an exception. The try-catch structure allows for the manipulation of these errors, enabling the application to continue running smoothly without abrupt termination.</li></ul><p><strong><em>Example:</em></strong></p><pre>try<br>{<br>    Console.WriteLine(&quot;Please Enter the first number: &quot;);<br>    int number1 = int.Parse(Console.ReadLine());<br><br>    Console.WriteLine(&quot;Please Enter the second number: &quot;);<br>    int number2 = int.Parse(Console.ReadLine());<br><br>    Console.WriteLine(&quot;Result: &quot; + (number1 + number2));<br>}<br>catch (FormatException)<br>{<br>    Console.WriteLine(&quot;Please enter a valid number.&quot;);<br>}</pre><p>In this example, if a non-integer value is entered for number1 or number2, a FormatException will be caught, and the message &quot;Please enter a valid number.&quot; will be displayed.</p><h4>Try-Catch Parameters:</h4><p>These parameters provide information about the errors encountered during runtime. For example, dividing a number by zero will cause an error. The error message “DivideByZeroException” indicates the type of error encountered.</p><p>The type of error thrown depends on the nature of the error. For instance, attempting to perform an operation on a null value will trigger a specific error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*gc6BZftJ8Ze8joHTIAR1QQ.png" /></figure><h4>Catch Block:</h4><p>The catch block is where the error is caught and handled. The syntax is as follows:</p><pre>try<br>{<br>    // Code that might throw an error<br>}<br>catch (Exception ex)<br>{<br>    // Code to handle the error<br>}</pre><p>The Exception type is a base type that can handle all errors. The ex parameter can be replaced with any desired name, such as message or warning. This parameter provides information about the error, which can be used for logging and other operations. If no parameter is defined, the catch block will still execute, but no error information will be available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*c-LnwSiSeQ54iisYl84tLA.png" /></figure><h4>Types of Errors:</h4><p>All error types are derived from the Exception class. While the catch block can catch all errors using the Exception type, it can also be tailored to catch specific types of errors.</p><p><strong><em>For example:</em></strong></p><pre>try<br>{<br>    int a = 0, b = 10;<br>    Console.WriteLine(b / a);<br>    int.Parse(&quot;abcdasa&quot;);<br>}<br>catch (FormatException ex)<br>{<br>    Console.WriteLine(&quot;Message: &quot; + ex.Message);<br>}<br>catch (DivideByZeroException ex)<br>{<br>    Console.WriteLine(&quot;Message: &quot; + ex.Message);<br>}</pre><p>In this example, the first catch block will handle FormatException, and the second catch block will handle DivideByZeroException. If an error of a different type occurs, it should be handled by defining another catch block for that specific error type.</p><p>When we run this code, it will return the following message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*ZrzzjqBrmaJlj-vapoC6hg.png" /></figure><h4>Try-Catch Error Types</h4><p>As shown below, all error types inherit from the Exception class, which means Exception is the base class for all error types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*jxaB9VXECH2IX7KsnpQsJg.png" /></figure><p>We can specify Exception as the parameter for the catch block, but we can also specify the error type based on the nature of the error. Let&#39;s explore handling errors with types other than Exception.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*LLcHKMropq5vsote7vtD0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*bcfKs3UGU4Mmw46cqhcPPw.png" /></figure><p>If the catch block does not define a parameter, it can handle all errors. If the parameter is defined as Exception, it will still handle all errors.</p><p>However, if the parameter is a specialized error type, it will only catch and handle errors of that specific type.</p><p>For example, if the parameter is defined as FormatException but the error type caught is DivideByZeroException, the catch block will not execute and a runtime error will be thrown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*Frm8ZEHIlS4Yu1BsxBuMsw.png" /></figure><p>In such cases, using multiple catch blocks to handle different error types is recommended.</p><h4>Multiple Catch Blocks:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*-dbHC9lb-MfB0iBf7h0-Rg.png" /></figure><p>In the example above, we have two types of errors but only a single catch block. In such a case, despite having two different error types, the same behavior will be exhibited. Therefore, it’s important to differentiate between various error types in the catch block to handle each error appropriately.</p><p>If multiple catch blocks are defined, the order of these blocks is crucial. For example:</p><pre>try<br>{<br>    // Code that might throw an error<br>}<br>catch (FormatException ex)<br>{<br>    // Handle FormatException<br>}<br>catch (DivideByZeroException ex)<br>{<br>    // Handle DivideByZeroException<br>}<br>catch (Exception ex)<br>{<br>    // Handle all other exceptions<br>}</pre><p>The Exception type catch block should be defined last, as it can catch all types of errors.</p><p><strong><em>Example:</em></strong></p><pre>try<br>{<br>    int a = 0, b = 10;<br><br>    Console.WriteLine(b/a);<br><br>    int.Parse(&quot;abcdasa&quot;);<br>}<br>catch (FormatException ex)<br>{<br>    Console.WriteLine(&quot;Message: &quot; + ex.Message);<br>}<br>catch (DivideByZeroException ex)<br>{<br>    Console.WriteLine(&quot;Message: &quot; + ex.Message);<br>}</pre><p>In this example, if a FormatException is encountered, the first catch block will execute. If a DivideByZeroExceptionoccurs, the second catch block will execute.</p><p>If an error of a different type occurs, a catch block handling that specific error type should be defined. If not all possible error types can be anticipated, a catch block with an Exception parameter should be defined as the last block to handle any unanticipated errors.</p><p>The try-catch structure checks for errors based on the order of the catch blocks. Therefore, the sequence of the catch blocks is important.</p><p>If multiple catch blocks are defined, the Exception type should be placed last to ensure it catches any errors not handled by the previous blocks.</p><h4>Try-Catch-Finally Block</h4><p>The finally block is executed regardless of whether an error occurs. It is used for code that must run in both scenarios.</p><pre>try<br>{<br>    // Code that might throw an exception<br>}<br>catch (Exception ex)<br>{<br>    // Handle the error<br>}<br>finally<br>{<br>    // Code that should run in both cases<br>}</pre><h4>Try-Catch-When Structure:</h4><p>The when keyword can be used to add conditions to the catch block.</p><pre>try<br>{<br>    // Code that might throw an error<br>}<br>catch (DivideByZeroException ex) when (a == 0)<br>{<br>    // Code to handle DivideByZeroException when a == 0<br>}<br>catch (DivideByZeroException ex) when (b == 0 &amp;&amp; a == 0)<br>{<br>    // Code to handle DivideByZeroException when b == 0 and a == 0<br>}</pre><p>In this example, the catch block will only execute if the specified condition is met.</p><h3>Logical Errors</h3><p>Logical errors arise from flaws in the program’s logic, flow, or algorithms, leading to incorrect results. Unlike syntax errors, logical errors do not prevent the code from compiling or executing. However, they cause the program to produce unintended outputs. These errors are often challenging to identify and resolve because they require comprehensive testing or feedback from users.</p><p><strong><em>Example:</em></strong></p><p>Consider the task of calculating the arithmetic mean of two variables, x and y.</p><pre>int x = 10, y = 20;<br>Console.WriteLine((x + y) / 2); // Correct calculation</pre><p>In this code, the arithmetic mean is correctly calculated as (10 + 20) / 2, which results in 15.</p><p>However, if the division by 2 is omitted, the code will yield incorrect results:</p><pre>int x = 10, y = 20;<br>Console.WriteLine(x + y); // Incorrect result, should be divided by 2</pre><p>Here, the output will be 30 instead of the correct mean of 15. This example illustrates how a logical error can lead to unexpected results despite the code running without any syntax issues. Identifying and fixing such errors typically involves careful review and testing to ensure that the program behaves as intended.</p><p><strong><em>Conclusion:</em></strong></p><p><em>Effectively managing errors during the software development process is essential for the success of your projects. In this article, you learned about various types of errors, from compiler errors to runtime and logical errors, and how to overcome them. To properly handle errors, continuously test and review your code. For more insights and content that will guide you through the software development process, be sure to follow me. I will continue sharing tips and strategies to assist you on your development journey.✨</em></p><p><strong><em>Acknowledgments:</em></strong></p><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21729da60827" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ultimate Guide to C# Pattern Matching: Boost Your Coding Efficiency]]></title>
            <link>https://medium.com/@eminy/ultimate-guide-to-c-pattern-matching-boost-your-coding-efficiency-52014d3c5988?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/52014d3c5988</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[pattern-matching]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[c-sharp-developer]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Sun, 04 Aug 2024 14:23:12 GMT</pubDate>
            <atom:updated>2024-08-04T14:23:12.613Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, and welcome back! In our last post, we explored the intricacies of conditional statements in C#, focusing on how they enable dynamic and responsive software development. Today, we are venturing into another essential feature of C#: Pattern Matching. Introduced in C# 7.0 and refined in later versions, pattern matching allows developers to check object types and shapes efficiently, leading to more readable and maintainable code. Whether you’re new to pattern matching or looking to deepen your understanding, this guide will provide you with a comprehensive overview of its various patterns and enhancements. Let’s dive in and unlock the power of C# pattern matching!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LSlYhZuU-v993yLT_u-drg.png" /></figure><h3>C# Pattern Matching: An Essential Guide</h3><h4>Enhancing Code Readability with Pattern Matching</h4><p>C# pattern matching, introduced in C# 7.0 and later versions, enhances the ability to check the types and shapes of objects. This feature makes the code more readable and easier to maintain. Pattern matching is especially used in switch and if statements, allowing for object checks with various patterns, including:</p><ul><li><strong>Type Pattern</strong></li><li><strong>Constant Pattern</strong></li><li><strong>Var Pattern</strong></li><li><strong>Recursive</strong></li></ul><h4>Mastering the Type Pattern</h4><p>The type pattern is a patterned version of the is operator used to determine the type within an object.</p><p>Using is for type determination:</p><pre>object x = 125;<br>if (x is string)<br>{<br>    string xx = x as string;<br>    Console.WriteLine(&quot;x is of type string&quot;);<br>}<br>if (x is int)<br>{<br>    int xx = (int)x;<br>    Console.WriteLine(&quot;x is of type int&quot;);<br>}</pre><p>Here, after determining the type with is, the value within the object is unboxed using as or a cast, and operations continue based on the type. This method makes the code lengthy. When using the type pattern:</p><pre>object x = 125;<br><br>if (x is string xx)<br>    Console.WriteLine(&quot;x is of type string&quot;);<br>else if (x is int xxx)<br>    Console.WriteLine(&quot;x is of type int&quot;);</pre><p>Here, there is no need for casting; the value will be directly unboxed into xx or xxx.</p><h4>Utilizing the Constant Pattern</h4><p>The constant pattern allows us to compare our data with a fixed value.</p><pre>object x = &quot;John&quot;;<br><br>if (x is &quot;John&quot;)<br>    Console.WriteLine(&quot;John&quot;);</pre><p>In this example, the control is performed with x is &#39;John&#39;, and the code process continues accordingly.</p><p>If type control is done with the is operator, it is not a constant pattern.</p><pre>if (x is string)<br>    Console.WriteLine(&quot;x is string&quot;);</pre><p>However, if value control rather than type control is performed, it is a constant pattern.</p><pre>if (x is 4)<br>    Console.WriteLine(&quot;x is 4&quot;);</pre><h4>Exploring the Var Pattern</h4><p>The var pattern allows us to get the data with the var variable.</p><pre>object x = &quot;Turkey&quot;;<br>if (x is var a)<br>{<br>    Console.WriteLine(a);<br>}</pre><p>Here, it allows the assignment of the value to a variable regardless of the type of x.</p><p><strong>Important Note:</strong> The type of the var keyword is determined at compile-time, while the type of the var pattern is determined at runtime.</p><p>When using the type pattern, if the value of the x variable is not of the relevant type, the variable may be null, which would cause an error if the variable is used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*QEub3GAbem8pvVzBn_XNBQ.png" /></figure><p>However, in the var pattern, since the value of the x variable will be assigned to the o variable regardless of its value, the ovariable will not be null, and it can be used safely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*zWqH9X-7jZnUUb8Q5sfd-Q.png" /></figure><h4>Unveiling the Recursive Pattern</h4><p>This pattern introduces many innovations in the switch-case structure. Reference type variables can also be checked in the switch block. Additionally, the switch block has gained various condition/qualification properties with the whencommand.</p><h3>Pattern Matching Enhancements in C# 9.0</h3><h4>Relational Pattern</h4><p>Operators like &lt;, &gt;, &lt;=, and &gt;= can be used in patterns, allowing for quick comparisons.</p><pre>int number = 111;<br>string result = number switch<br>{<br>    &lt; 50 =&gt; &quot;Less than 50&quot;,<br>    &gt; 50 =&gt; &quot;Greater than 50&quot;,<br>    50 =&gt; &quot;Equal to 50&quot;,<br>};</pre><p>The switch statement, which was essentially an equality check control flow, can now perform other types of comparisons with the relational pattern.</p><h4>Logical Pattern</h4><p>Logical operators like and, or, and not can be used.</p><p><em>Example:</em></p><pre>int number = 111;<br>string result = number switch<br>{<br>    &gt; 10 and &lt; 50 =&gt; &quot;Greater than 10 and less than 50&quot;,<br>    &gt; 50 and &lt; 100 =&gt; &quot;Greater than 50 and less than 100&quot;,<br>    not 100 =&gt; &quot;Not equal to 100&quot;,<br>    100 =&gt; &quot;Equal to 100&quot;,<br>};</pre><p><strong><em>Conclusion:</em></strong></p><p><em>✨ Mastering pattern matching in C# is crucial for developing efficient and robust software. By utilizing type patterns, constant patterns, var patterns, and more, you can create code that is both dynamic and adaptable to various conditions. This guide has provided an in-depth overview of these fundamental tools, but remember, the best way to deepen your understanding is through continuous practice and exploration. Stay tuned for more insights, and happy coding! Don’t forget to follow me for more updates and tutorials. ✨</em></p><p><strong><em>Acknowledgments:</em></strong></p><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52014d3c5988" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Conditional Statements in C#: If-Else and Switch-Case Explained]]></title>
            <link>https://medium.com/@eminy/mastering-conditional-statements-in-c-if-else-and-switch-case-explained-2c14640c999c?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c14640c999c</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[if-else]]></category>
            <category><![CDATA[conditional-statements]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[switch-case]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 20:35:46 GMT</pubDate>
            <atom:updated>2024-08-04T14:16:42.836Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, and welcome back! In our last post, we dove deep into the world of operators in C#, exploring how they form the building blocks of any program by manipulating data and variables. Today, we’re going to take another crucial step in your programming journey by uncovering the secrets of Conditional Statements in C#. Understanding how to direct the flow of your code using these conditional statements is essential for creating dynamic and responsive software applications. From the simplicity of if-else statements to the versatility of switch-case structures, mastering these flow control mechanisms will significantly enhance your coding skills. So, let’s get started and unlock the potential of Conditional Statements in C#!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*wv2Bu1WkVVysl_NB8rvh6g.png" /></figure><h3>What Are Conditional Statements?</h3><p>Conditional statements are structures in programming that allow us to direct the flow of code based on specific conditions, enabling the execution of different algorithms, code blocks, or structures.</p><p>These mechanisms include:</p><ul><li><strong>If-else</strong></li><li><strong>Switch-case</strong></li></ul><p>Conditional statements guide the software code’s execution based on conditions. For instance, in everyday life, if you are told to take an umbrella if it rains, it is a condition-based directive. The action of taking an umbrella is contingent on the condition of rain.</p><p>Conditional statements are crucial structures extensively used in algorithms, making them indispensable for developers.</p><p><strong>If-Else and Switch Structures</strong></p><p>If-else and switch structures serve similar purposes in controlling the flow of a program based on conditions but differ in their implementation. Despite technical differences, their operational use and objectives are aligned.</p><h3>Switch Case</h3><p>The switch-case structure is one of the constructs that allow us to direct the flow of code based on specific conditions in our algorithms. But what makes the switch unique?</p><p>The switch-case structure can only be used to check equality conditions of a variable. For other comparisons like greater than, less than, etc., we use the if structure.</p><blockquote><strong><em>Remember!</em></strong><em> Switch can only be used if an equality condition is being checked. After C# 7.0, pattern matching introduced new features to the switch block, allowing more complex comparisons beyond simple equality. These will be discussed in later sections.</em></blockquote><p><em>Switch-case syntax:</em></p><pre>switch(variable)<br>{<br> case value1:<br> // code to execute<br> break;<br> case value2:<br> // code to execute<br> break;<br> default:<br> // code to execute if no cases match<br> break;<br>}</pre><p>In the switch structure, case value1: is used to check the value of the variable. The : after case value is mandatory. The break statement ensures that once a case matches, the code block is executed, and the switch block is exited.</p><p><em>Example:</em></p><pre>string name = &quot;John&quot;;<br><br>switch (name)<br>{<br>    case &quot;Anna&quot;:<br>        Console.WriteLine(&quot;Name is Anna&quot;);<br>        break;<br>    case &quot;Kris&quot;:<br>        Console.WriteLine(&quot;Name is Kris&quot;);<br>        break;<br>    case &quot;John&quot;:<br>        Console.WriteLine(&quot;Name is John&quot;);<br>        break;<br>    default:<br>        Console.WriteLine(&quot;No name&quot;);<br>        break;<br>}</pre><p>This will output “Name is John”. If the name were something else, the default block would execute.</p><h4>Rules:</h4><ol><li>The type being checked in the switch must be the same in the case blocks. For instance, if the variable is a string, the case values must also be strings. Otherwise, the compiler will throw an error.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*qvTLR0yP2CX0qGtu8FgPdA.png" /></figure><p>2. The value in the switch parentheses can be a variable or a constant/static value, while the values in the case blocks must be constant/static. If variables are used in the cases, it will result in an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*CMtcRANK98S3r_sKf_3Xpw.png" /></figure><p>3. The default block is executed if none of the cases match. It is not mandatory but ensures that some code executes if no case matches.</p><h4>Switch Case — Using the when Keyword</h4><p>The when keyword can be used to add additional conditions to a switch case.</p><p><em>Syntax:</em></p><pre>switch(variable)<br>{<br>    case value1 when condition:<br>        // code to execute<br>        break;<br>}</pre><p><em>Example:</em></p><pre>string name = &quot;John&quot;;<br>int age = 15;<br><br>switch (name)<br>{<br>    case &quot;Anna&quot; when age == 13:<br>        Console.WriteLine(&quot;Name is Anna&quot;);<br>        break;<br>    case &quot;John&quot; when age == 23:<br>        Console.WriteLine(&quot;Name is John&quot;);<br>        break;<br>    case &quot;John&quot;:<br>        Console.WriteLine(&quot;Name is John&quot;);<br>        break;<br>    default:<br>        Console.WriteLine(&quot;No name&quot;);<br>        break;<br>}</pre><p>It checks both the name and the age condition, and provides the output ‘Name is John’.</p><h4>Switch Case — Using the goto Keyword</h4><p>In a switch-case structure, only equality checks can be performed. Sometimes, you may need to apply the same operation or code flow across different equality cases. Typically, your code might look like this:</p><pre>switch (variable)<br>{<br>    case value1:<br>        // Perform operation A<br>        break;<br>    case value2:<br>        // Perform operation B<br>        break;<br>    case value3:<br>        // Perform operation A<br>        break;<br>    case value4:<br>        // Perform operation A<br>        break;<br>}</pre><p>In this code block, you can see that operation A is being repeated multiple times. To avoid redundancy, you can use the goto keyword to jump to another case. This allows you to transition between cases and reuse code efficiently:</p><pre>switch (variable)<br>{<br>    case value1:<br>        // Perform operation A<br>        break;<br>    case value2:<br>        // Perform operation B<br>        break;<br>    case value3:<br>        goto case value1;<br>    case value4:<br>        goto case value1;<br>}</pre><p>This approach helps you avoid code repetition and makes your switch-case structure more maintainable.</p><p><strong>Additionally, when using the </strong><strong>goto keyword to direct multiple cases to the same case, you can structure your code as follows:</strong></p><pre>switch (variable)<br>{<br>    case value1:<br>        // Perform operation A<br>        break;<br>    case value2:<br>        // Perform operation B<br>        break;<br>    case value3:<br>    case value4:<br>        goto case value1;<br>}</pre><p>In this scenario, if either value3 or value4 is encountered, it will be directed to case value1.</p><p><em>Example:</em></p><pre>int age = 17;<br><br>switch (age)<br>{<br>    case 21:<br>        Console.WriteLine(&quot;Older than 18&quot;);<br>        break;<br>    case 13:<br>        Console.WriteLine(&quot;Younger than 18&quot;);<br>        break;<br>    case 17:<br>        goto case 13;<br>}</pre><p>Here, since the value is 17, the code enters the case 17 block, which redirects to case 13, executing the code there and outputting &quot;Younger than 18&quot;.</p><h4>Switch Expressions</h4><p>Switch Expressions are constructs introduced with C# 8.0. They provide cost-effective and convenient semantics for single-line operations. In other words, if the operation involves a single line and the result is assigned to a variable, Switch Expressions can be used.</p><p><em>Syntax:</em></p><pre>string output = variable switch<br>{<br>    value1 =&gt; &quot;output for value1&quot;,<br>    value2 =&gt; &quot;output for value2&quot;,<br>    _ =&gt; &quot;default output&quot;<br>};</pre><p><em>Example Without Switch Expressions:</em></p><pre>string message = &quot;&quot;;<br>string week = &quot;Monday&quot;;<br><br>switch (week)<br>{<br>    case &quot;Monday&quot;:<br>        message = &quot;Today is Monday&quot;;<br>        break;<br>    case &quot;Tuesday&quot;:<br>        message = &quot;Today is Tuesday&quot;;<br>        break;<br>    case &quot;Wednesday&quot;:<br>        message = &quot;Today is Wednesday&quot;;<br>        break;<br>    // more cases<br>}<br>Console.WriteLine(message);</pre><p><em>Example With Switch Expressions:</em></p><pre>string week = &quot;Monday&quot;;<br>string message = week switch<br>{<br>    &quot;Monday&quot; =&gt; &quot;Today is Monday&quot;,<br>    &quot;Tuesday&quot; =&gt; &quot;Today is Tuesday&quot;,<br>    &quot;Wednesday&quot; =&gt; &quot;Today is Wednesday&quot;,<br>    // more cases<br>};<br>Console.WriteLine(message);</pre><h4>Switch Expressions with When</h4><p>Switch expressions can also use the when keyword.</p><p><em>Example:</em></p><pre>string name = &quot;John&quot;;<br>int age = 3;<br><br>string message = name switch<br>{<br>    &quot;John&quot; when age == 1 =&gt; &quot;John is 1 year old&quot;,<br>    &quot;John&quot; when age == 3 =&gt; &quot;John is 3 years old&quot;,<br>    &quot;Anna&quot; when age == 2 =&gt; &quot;Anna is 2 years old&quot;,<br>    &quot;Kris&quot; when age == 3 =&gt; &quot;Kris is 3 years old&quot;,<br>};<br>Console.WriteLine(message);</pre><p><em>Example:</em></p><pre>string name = &quot;John&quot;;<br>int age = 15;<br><br>string message = (name, age) switch<br>{<br>    (&quot;Anna&quot;, 12) =&gt; &quot;Name is Anna&quot;,<br>    (&quot;Kris&quot;, 11) =&gt; &quot;Name is Kris&quot;,<br>    (&quot;John&quot;, 14) =&gt; &quot;Name is John. John is 14 years old&quot;,<br>    (&quot;John&quot;, 15) =&gt; &quot;Name is John. John is 15 years old&quot;,<br>    _ =&gt; &quot;No name&quot;<br>};<br>Console.WriteLine(message);</pre><h4>Using the when Condition with Tuple Patterns</h4><p>Here’s an example of how to use the when condition with tuple patterns in a switch expression:</p><pre>string name = &quot;John&quot;;<br>int age = 15;<br><br>string message = (name, age) switch<br>{<br>    (&quot;Anna&quot;, 12) when 3 == 3 =&gt; &quot;Name is Anna&quot;,<br>    (&quot;Kris&quot;, 11) when 3 == 5 =&gt; &quot;Name is Kris&quot;,<br>    (&quot;John&quot;, 14) when 3 &gt;= 5 =&gt; &quot;Name is John. John is 14 years old&quot;,<br>    (&quot;John&quot;, 15) when 3 &lt;= 5 =&gt; &quot;Name is John. John is 15 years old&quot;,<br>    _ =&gt; &quot;No matching case&quot;<br>};<br><br>Console.WriteLine(message);</pre><p>In this code, the switch expression evaluates the tuple (name, age) and uses the when condition to add additional checks for each case.</p><h3>If-Else</h3><p>If-else is another fundamental conditional statement mechanism allowing code execution based on conditions. Unlike switch, which only checks equality, if-else can perform a variety of comparisons.</p><p>The if structure determines whether a piece of code will execute based on a condition.</p><p><em>Syntax:</em></p><pre>if(condition)<br>{<br>    // code to execute if condition is true<br>}</pre><ul><li>The condition must be of type bool.</li><li>All comparison and logical operators can be used here.</li></ul><p><em>Example:</em></p><pre>bool isMarried = true;<br>if(isMarried)<br>{<br>    Console.WriteLine(&quot;Married&quot;);<br>}</pre><p>You don’t have to use else in an if structure. If the condition is not met, the program continues without entering the if block.</p><pre>int i = 10;<br>if(i == 10)<br>{<br>    Console.WriteLine(&quot;Hello&quot;);<br>}<br>Console.WriteLine(&quot;World&quot;);</pre><p>If the condition is met and true, it enters the if block, prints “Hello”, then exits the if block and prints “World”. What happens if the condition is false?</p><pre>int i = 10;<br>if(i == 4)<br>{<br>    Console.WriteLine(&quot;Hello&quot;);<br>}<br>Console.WriteLine(&quot;World&quot;);</pre><p>If the condition is not met and false, it does not enter the if block and directly prints “World”.</p><p>Since the type of the variable in the if block is already bool, we do not have to use a comparison operator.</p><pre>bool maritalStatus = true;<br>if(maritalStatus) // Writing maritalStatus is sufficient. If you want to negate it, writing !maritalStatus is sufficient.<br>{<br>    Console.WriteLine(&quot;Married&quot;);<br>}</pre><h4>If-Else If Structure</h4><p>If-else if allows checking multiple conditions.</p><p><em>Syntax:</em></p><pre>if(condition1)<br>{<br>    // code if condition1 is true<br>}<br>else if(condition2)<br>{<br>    // code if condition2 is true<br>}<br>else<br>{<br>    // code if neither condition is true<br>}</pre><p>You can add as many else-if blocks as needed. If any of the if conditions are satisfied, the remaining if conditions will not be evaluated.</p><p><em>Example:</em></p><pre>int i = 10;<br>if(i &gt; 5 &amp;&amp; i &lt;= 10)<br>{<br>    Console.WriteLine(&quot;i is between 5 and 10&quot;);<br>}<br>else if(i &gt; 10 &amp;&amp; i &lt;= 20)<br>{<br>    Console.WriteLine(&quot;i is between 10 and 20&quot;);<br>}<br>else<br>{<br>    Console.WriteLine(&quot;i is greater than 20&quot;);<br>}</pre><h4>Important Notes:</h4><ul><li><strong>Execution Order:</strong> If-else if structures are evaluated from top to bottom. Once a condition is true, the rest are skipped.</li><li><strong>Code Duplication:</strong> Avoid duplicating code within if-else blocks by placing common code outside the blocks.</li></ul><pre>int i = 10;<br>if(i &gt;= 10)<br>{<br>    Console.WriteLine(&quot;i is 10 or greater&quot;);<br>    Console.WriteLine(&quot;Hello&quot;);<br>}<br>else<br>{<br>    Console.WriteLine(&quot;i is less than 10&quot;);<br>    Console.WriteLine(&quot;Hello&quot;);<br>}</pre><p><em>Improved version:</em></p><pre>if(i &gt;= 10)<br>{<br>    Console.WriteLine(&quot;i is 10 or greater&quot;);<br>}<br>else<br>{<br>    Console.WriteLine(&quot;i is less than 10&quot;);<br>}<br>Console.WriteLine(&quot;Hello&quot;);</pre><h3>Scopeless If Structure</h3><p>For single-line operations, you can omit braces.</p><pre>if(true)<br>    Console.WriteLine(&quot;...&quot;);<br><br>if(true)<br>{<br>    Console.WriteLine(&quot;...&quot;);<br>}</pre><p>For complex operations, braces are mandatory.</p><p><strong>In conclusion</strong>, conditional statements such as if-else and switch-case are essential for directing the execution flow of code based on conditions. Understanding their syntax and usage will enhance your programming skills and enable you to write more efficient and readable code.</p><p><strong><em>Conclusion</em></strong></p><p><em>✨ Grasping the intricacies of conditional statements in C# is vital for developing efficient and robust software. By leveraging if-else statements and switch-case structures, you can craft code that is both dynamic and adaptable to varying conditions. This guide has provided a comprehensive overview of these fundamental tools, but remember, the best way to deepen your understanding is through continuous practice and exploration. Stay tuned for more insights and happy coding! Don’t forget to follow me for more updates and tutorials. ✨</em></p><p><strong><em>Acknowledgments</em></strong></p><blockquote><strong>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c14640c999c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Operators in C#: A Comprehensive Guide]]></title>
            <link>https://medium.com/@eminy/mastering-operators-in-c-a-comprehensive-guide-deabbc90c89f?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/deabbc90c89f</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[operators-in-c-sharp]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 22:30:47 GMT</pubDate>
            <atom:updated>2024-08-04T14:14:18.186Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome! In this article, we will explore the integral concept of operators in C# programming. Operators are essential components that enable the execution of various operations within your code. By mastering the use of operators, you will enhance your ability to manipulate data and improve the overall efficiency of your programming endeavors. Let’s get started on this fundamental topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vYOsFciVUaitPyurtMR_4A.png" /></figure><h4>What is an Operator in Programming?</h4><p>Operators are fundamental building blocks that take responsibility for executing operations. Essentially, they are symbolic or textual structures that assume specific responsibilities, tasks, or operations on our behalf.</p><p><strong>Operator Literacy</strong></p><p>Operators typically perform mathematical, logical, or other operational tasks between two values. The result of these operations is usually returned as a value.</p><p><strong><em>Attention must be paid to the return values when using operators.</em></strong></p><h3>1- Arithmetic Operators</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*SMakZbuFly1P90-QjcEgjQ.png" /></figure><p>Arithmetic operators handle numerical operations. The main operators are:</p><ul><li><strong>+ (Addition)</strong></li><li><strong>- (Subtraction)</strong></li><li><strong>* (Multiplication)</strong></li><li><strong>/ (Division)</strong></li><li><strong>% (Modulus)</strong></li></ul><p><strong>Return Value of Arithmetic Operators</strong> Since arithmetic operators perform operations on two numerical values, the result returned will be of the appropriate type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*shzC2sH5AAE2J8C850130g.png" /></figure><p>In this example, since the variables a and b are of type int, the variable c will also be of type int.</p><p>When operating on numerical values of the same type, the result will also be of the same type.</p><p>But is it possible to perform arithmetic operations on values of different types? Let’s explore!</p><blockquote><strong>Performing Operations on Different Types:</strong></blockquote><p>When performing arithmetic operations on numerical values of different types, the result will be of the larger type. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*S4WuiWeTJMdPGy6ckkg7sQ.png" /></figure><p>In this example, a is of type int and b is of type double. The smaller type, int, is converted to the larger type, double, and the result is of type double.</p><blockquote><strong>Exception for Byte Type:</strong></blockquote><p>As a general rule, when performing arithmetic operations on two values of the same type, the result is returned in the same type. However, there is an exception for the byte type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*5t_nggoGojBAmTjAbheSSw.png" /></figure><p>In this example, although a and b are of type byte, the result is returned as int. This is a general rule that arithmetic operations on two byte values always return an int result.</p><h4>Order Of Operations In Mathematical Calculations:</h4><p>In programming, the order of operations found in classic mathematics also applies. These rules are:</p><ol><li>Operations within parentheses are performed first.</li><li>Multiplication (*) and division (/) operations are performed before addition (+) and subtraction (-) operations.</li><li>Operations are performed from left to right.</li></ol><p><em>For example:</em></p><pre>int result = 10 + 2 * 5; // 2 * 5 is performed first, then 10 + 10 is performed. The result will be 20.<br>int result2 = (10 + 2) * 5; // The operation within parentheses is performed first: 10 + 2, then 12 * 5 is performed. The result will be 60.</pre><h3>2- COMPARISON OPERATORS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*hJWJ6x1tlqfrtDMT6-ZTXw.png" /></figure><p>Comparison operators compare two numerical values based on their size, lesser or greater, and equality. Here are the operators and their meanings:</p><ul><li><strong>&lt; (less than)</strong>: Checks if the value on the left is less than the value on the right.</li></ul><blockquote>Example: 5 &lt; 10 returns true because 5 is less than 10.</blockquote><ul><li><strong>&gt; (greater than)</strong>: Checks if the value on the left is greater than the value on the right.</li></ul><blockquote>Example: 10 &gt; 5 returns true because 10 is greater than 5.</blockquote><ul><li><strong>&lt;= (less than or equal to)</strong>: Checks if the value on the left is less than or equal to the value on the right.</li></ul><blockquote>Example: 5 &lt;= 10 returns true because 5 is less than 10.</blockquote><ul><li><strong>&gt;= (greater than or equal to)</strong>: Checks if the value on the left is greater than or equal to the value on the right.</li></ul><blockquote>Example: 10 &gt;= 5 returns true because 10 is greater than 5.</blockquote><ul><li><strong>== (equal to)</strong>: Checks if the value on the left is equal to the value on the right.</li></ul><blockquote>Example: 5 == 5 returns true because 5 is equal to 5.</blockquote><blockquote><strong>Return Value of Comparison Operators</strong></blockquote><p>Comparison operators always return a boolean value. This means the result of a comparison will always be either true or false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*yn0Swl9_U6U70dNg3C82gw.png" /></figure><p><em>For Example:</em></p><pre>int a = 5;<br>int b = 10;</pre><pre>bool result1 = a &lt; b;  // result1 will be true<br>bool result2 = a &gt; b;  // result2 will be false<br>bool result3 = a &lt;= b; // result3 will be true<br>bool result4 = a &gt;= b; // result4 will be false<br>bool result5 = a == b; // result5 will be false</pre><h3>3- LOGICAL OPERATORS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*6UI4UGQ-ON4ku65zIjm6HQ.png" /></figure><p>Logical operators evaluate all conditions and return a result based on their logic.</p><ul><li>&amp;&amp; (and)</li><li>|| (or)</li><li>^ (xor)</li></ul><blockquote><strong>&amp;&amp; (and):</strong></blockquote><p>The and operator requires all conditions to be met. For example, if a customer goes to a restaurant and tells the waiter they want potatoes and meatballs, the waiter is required to bring both potatoes and meatballs;</p><p><em>Potatoes and Meatballs</em></p><blockquote>True &amp;&amp; True</blockquote><blockquote><strong>| | (or):</strong></blockquote><p>The or operator requires at least one of the conditions to be met. For instance, if a customer tells the waiter to bring either mayonnaise or ketchup, the waiter is required to bring either mayonnaise or ketchup, or both.</p><p><em>Mayonnaise or Ketchup</em></p><blockquote>True | | True</blockquote><blockquote>True | | False</blockquote><blockquote>False || True</blockquote><blockquote><strong>^ (xor):</strong></blockquote><p>The xor operator requires exactly one of the conditions to be met. If the customer asks for either water or cola, the waiter will bring either water or cola but not both.</p><p><em>Water or Cola</em></p><blockquote>True ^ False</blockquote><blockquote>False ^ True</blockquote><blockquote><strong>Logical Operator Usage</strong></blockquote><p>Logical operators are used on logical values, meaning the values on the left and right must be of boolean type. Logical operators perform operations on boolean values and return a boolean value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*U__Ww6U4QoAHzALLLYAtLQ.png" /></figure><p><strong>Return Values of Logical Operators:</strong></p><p><strong>&amp;&amp; (and):</strong></p><ul><li>true &amp;&amp; true = true</li><li>false &amp;&amp; true = false</li><li>true &amp;&amp; false = false</li><li>false &amp;&amp; false = false</li></ul><p><strong>| | (or):</strong></p><ul><li>true || true = true</li><li>false || true = true</li><li>true || false = true</li><li>false || false = false</li></ul><p><strong>^ (xor):</strong></p><ul><li>true ^ true = false</li><li>false ^ true = true</li><li>true ^ false = true</li><li>false ^ false = false</li></ul><p><strong><em>Try solving the following operation yourself:</em></strong></p><pre>Console.WriteLine(((true &amp;&amp; true) || false &amp;&amp; ((true ^ false) &amp;&amp; false) || true ))</pre><h3>4- INCREMENT AND DECREMENT OPERATORS</h3><p><strong>++ (Increment) and </strong><strong>-- (Decrement):</strong> These operators increase or decrease a numerical value by 1. They are commonly used in loops or for updating numerical values.</p><p><strong>Usage Examples:</strong></p><ul><li>The statement i++ is equivalent to i = i + 1 and increases the value of the variable i by 1.</li><li>The statement j-- is equivalent to j = j - 1 and decreases the value of the variable j by 1.</li></ul><p><em>Examples:</em></p><ul><li><strong>Increment:</strong></li></ul><pre>int i = 5;<br>i++; // This is equivalent to i = i + 1; Now, i will be 6.</pre><ul><li><strong>Decrement:</strong></li></ul><pre>int j = 10;<br>j--; // This is equivalent to j = j - 1; Now, j will be 9.</pre><p><strong>Return Value of Increment and Decrement Operators:</strong> These operators return the value of the variable after the operation.</p><p><em>Without using the increment operator:</em></p><pre>i = i + 1;<br>Console.WriteLine(i);</pre><p><em>Using the increment operator:</em></p><pre>Console.WriteLine(i++); // This is sufficient.</pre><p><strong><em>Important!</em></strong></p><p><strong>There is a technical difference between </strong><strong>++i and </strong><strong>i++.</strong></p><ul><li><strong>++i (Pre-Increment):</strong> Increments the value of i by 1 first, then returns the new value.</li></ul><pre>int i = 10;<br>Console.WriteLine(++i); // i is incremented to 11 first, then 11 is printed.</pre><ul><li><strong>i++ (Post-Increment):</strong> Returns the current value of i first, then increments the value by 1.</li></ul><pre>int i = 10;<br>Console.WriteLine(i++); // The current value of i (10) is printed first, then i is incremented to 11.</pre><p><em>Example:</em></p><pre>int a = 5;<br>int b = a++;<br>Console.WriteLine(a); // The value of a is 6 because a was incremented by 1.<br>Console.WriteLine(b); // b is assigned the value of a before incrementing (5).</pre><h3>5- COMPOUND ASSIGNMENT OPERATORS</h3><p><strong>Compound Assignment Operators</strong> are used to perform an operation on a variable’s current value and then assign the result back to that variable. These operators make the code shorter and more readable. The compound assignment operators used for basic arithmetic operations are:</p><ul><li>+= (Addition and Assignment)</li><li>-= (Subtraction and Assignment)</li><li>*= (Multiplication and Assignment)</li><li>/= (Division and Assignment)</li><li>%= (Modulus (remainder) and Assignment)</li></ul><pre>int i = 1;<br>i = i + 3; // This can be written as:<br>i += 3; // Equivalent to i = i + 3.<br>i -= 3;<br>i *= 3;<br>i /= 3;</pre><h3>6- OPERATORS FOR STRING EXPRESSIONS</h3><p>There are three operators for string expressions: +, +=, and ==.</p><ul><li>+<strong> Operator:</strong> String expressions can be concatenated using the + operator.</li></ul><pre>string x = &quot;John&quot;;<br>string y = &quot;Mary&quot;;<br>Console.WriteLine(x + y); // The result is JohnMary.</pre><ul><li>&quot;John&quot; + &quot;Mary&quot; ifadesi &quot;JohnMary&quot; sonucunu verir. Ayrıca, bir dize ifadesini başka bir tür ifadesiyle (örneğin bir sayı) birleştirdiğinizde, sonuç her zaman bir dize olur. Örneğin, &quot;John&quot; + 4 ifadesi &quot;John4&quot; sonucunu verir;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*KI5z_cIKBbsgz7fwVKTjLg.png" /></figure><p><strong>Note</strong>: To convert any value to a string, you can use the .ToString method. Additionally, concatenating a value with a string using the + operator will convert it to a string.</p><ul><li><strong>+= Operator: </strong>Used to append a new string to an existing string. This operator is shorthand for a = a + b;.</li></ul><p>Eğer a değişkeninde &quot;John&quot; ve b değişkeninde &quot;Mary&quot; varsa, a += b; ifadesi a değişkenini &quot;JohnMary&quot; olarak günceller.</p><pre>string a = &quot;John&quot;;<br>string b = &quot;Mary&quot;;<br>a = a + b;<br>Console.WriteLine(a); // The result is JohnMary.</pre><p><em>Instead of:</em></p><pre>a = a + b;</pre><p><em>We can use:</em></p><pre>a += b;</pre><ul><li><strong>== and </strong><strong>!= Operators</strong>: Used to compare two strings. The == operator checks if two strings are equal, while the != operator checks if they are different.</li></ul><p><strong><em>Example</em></strong><em>:</em></p><ul><li>a == b checks if a and b are equal, returning true if they are, and false otherwise.</li><li>a != b checks if a and b are different, returning true if they are, and false otherwise.</li></ul><pre>string a = &quot;John&quot;;<br>string b = &quot;Mary&quot;;<br>Console.WriteLine(a == b); // Checks if a and b are equal.<br>Console.WriteLine(a != b); // Checks if a and b are different.</pre><p><strong><em>Case sensitivity applies, so comparing “John” with “john” will return false.</em></strong></p><h3>7- The ! Operator</h3><p>The ! operator is used to invert boolean values and to perform &quot;not equal&quot; checks in comparison expressions. Here are the details:</p><p><strong><em>Logical Negation:</em></strong></p><ul><li>The ! operator inverts a boolean (true/false) value.</li><li>For example, !true returns false, and !false returns true.</li></ul><p><strong><em>Usage in Comparisons:</em></strong></p><ul><li>The != operator checks if two values are not equal.</li><li>For example, the expression a != b checks if the variables a and b are not equal, returning true if they are not equal and false if they are equal.</li></ul><p><em>Example:</em></p><pre>int i = 3;<br>int i2 = 5;<br>Console.WriteLine(!(i == i2)); // Here, if `i` and `i2` are not equal, it returns `true`. If they are equal, it returns `false`. The expression `(i == i2)` returns `false`, but the `!` operator negates this, so the result is `true`.</pre><p><em>In this example, since the values of </em><em>i and </em><em>i2 are not equal, the expression </em><em>(i == i2) returns </em><em>false. The </em><em>! operator inverts this result, giving </em><em>true.</em></p><p>Thus, the ! operator is used to negate conditions or to perform &quot;not equal&quot; checks in comparisons.</p><h3>8- TERNARY OPERATOR (?:)</h3><p>The ternary operator allows you to assign a value to a variable/property/method based on a condition in a single line. It simplifies the code compared to a traditional if-else statement.</p><p><em>Using if-else Statement for Similar Operation:</em></p><pre>if (maritalStatus == true)<br>{<br>    string message = &quot;campaign for married people&quot;;<br>}<br>else<br>{<br>    string message = &quot;campaign for single people&quot;;<br>}</pre><p>Instead of writing lengthy code, the ternary operator simplifies it to a single line and checks the condition within its syntax, returning the appropriate value.</p><p><strong>Syntax:</strong> The general syntax of the ternary operator is:</p><blockquote>condition ? value_if_true : value_if_false</blockquote><ul><li><strong>Condition:</strong> A comparison or logical operation that returns a boolean value.</li><li><strong>value_if_true:</strong> The value returned if the condition is true.</li><li><strong>value_if_false:</strong> The value returned if the condition is false.</li></ul><p><strong><em>Example Usage:</em></strong></p><ul><li><strong><em>Simple Condition:</em></strong></li></ul><pre>bool maritalStatus = true;<br>string message = maritalStatus == true ? &quot;Married&quot; : &quot;Single&quot;;</pre><p>In this example, if the maritalStatus variable is true, the message variable is assigned &quot;Married&quot;; otherwise, it is assigned &quot;Single.&quot;</p><ul><li><strong><em>Multiple Conditions:</em></strong></li></ul><pre>int age = 34;<br>string result = age &lt; 25 ? &quot;A&quot; : (age == 25 ? &quot;B&quot; : &quot;C&quot;);</pre><p>In this example, if the age variable is less than 25, &quot;A&quot; is assigned; if it equals 25, &quot;B&quot; is assigned; and if it is greater than 25, &quot;C&quot; is assigned.</p><p><strong>Note:</strong></p><ul><li>Console.WriteLine outputs a value to the screen.</li><li>Console.ReadLine prompts the user for input.</li></ul><p>The ternary operator is useful for making your code shorter and more readable, especially for simple conditional assignments.</p><h3>9- ASSIGN OPERATOR (=):</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*h_iDrPGupSeoOt0ofSDr-Q.png" /></figure><p>The assign operator is used to assign a value to a variable. The variable on the left side of the operator is assigned the value on the right side.</p><pre>int a = 5; // assigns the value 5 to the variable &#39;a&#39;</pre><ul><li>When a variable is called on the left side of the assign operator, it refers to the variable itself, but when called on the right side, it refers to the value of the operator.</li><li>Future writings will explore how the assignment operator works with reference type variables and how it transforms into a reference operator. This is important for understanding the differences between value types and reference types.</li></ul><h3>10- MEMBER ACCESS OPERATOR (.):</h3><p>The member access operator (.) allows you to operate on the members (methods, properties, fields) of a value based on its type. Here are the details:</p><p><strong><em>Member Access:</em></strong></p><ul><li>The . operator is used to access a member (method, property, field, etc.) within an object or variable.</li><li>For example, this operator is used to call a property or method of a class.</li></ul><p><strong><em>Continuing Code:</em></strong></p><ul><li>The member access operator enables you to continue the code by allowing you to utilize the specific attributes and behaviors of the object.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*TSQaCJDCRryTsRslDh71wA.png" /></figure><h3>11- CAST OPERATOR (( )):</h3><p>The cast operator is used to convert a value to a specified type. For example, the expression (int)x converts the variable x to the int type.</p><p><strong>Syntax:</strong></p><blockquote>(type)value // converts the value to the specified type</blockquote><ol><li><strong>Unboxing: </strong>It is used to convert a value of type object to a more specific type. For example, object x = 5; int y = (int)x; converts the variable x to the int type.</li><li><strong>Explicit Type Conversion: </strong>It is used when converting from one type to another. For example, int x = 5; byte y = (byte)x; converts the int type value of x to the byte type.</li><li><strong>Conversion</strong> <strong>Between Char and Int:</strong> It performs conversions between char and int types using ASCII codes. For example, char x = &#39;a&#39;; int y = (int)x; converts the char type value of x to its ASCII code as an int.</li></ol><blockquote><strong>Unboxing</strong>:</blockquote><pre>object x = 5;<br>int y = (int)x;</pre><blockquote><strong>Explicit Type Conversion</strong>:</blockquote><pre>int x = 5;<br>byte y = (byte)x;</pre><blockquote><strong>Conversion</strong> <strong>Between Char and Int:</strong></blockquote><pre>char x = &#39;a&#39;;<br>int y = (int)x;</pre><p>Another future usage I’ll discuss is obtaining an object pointed to by a base class reference in its own type during polymorphism, similar to unboxing.</p><h3>12- SIZEOF OPERATOR (sizeof):</h3><p>The sizeof operator returns the size of a given type in bytes. This provides information about the memory usage of different data types.</p><p><strong>Syntax:</strong></p><blockquote>sizeof(type)</blockquote><pre>Console.WriteLine(&quot;int: &quot; + sizeof(int));<br>Console.WriteLine(&quot;long: &quot; + sizeof(long));<br>Console.WriteLine(&quot;decimal: &quot; + sizeof(decimal));</pre><p>This operator is used to determine how much memory a type occupies and is generally useful for performance analysis, memory management, or optimizing data structures.</p><h3>13- TYPEOF OPERATOR (typeof):</h3><p>The typeof operator returns the Type object for a given type. It is used to obtain information about that type. For example, if you want to examine the properties or methods of a type, you can use the typeof operator to retrieve this information.</p><p><strong><em>Syntax:</em></strong></p><blockquote>Type t = typeof(type);</blockquote><p><strong>Usage:</strong> The expression Type t = typeof(type); assigns all the information about the specified type to the variable t. This variable provides access to the metadata of the type (e.g., properties, methods, type name, etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*npe9a3jBf7PhCvVuP7UvLQ.png" /></figure><p><em>Example Usage:</em></p><pre>Type t = typeof(int); // The &#39;int&#39; type information is assigned to the &#39;t&#39; variable.<br>Console.WriteLine(t.FullName); // Output: System.Int32</pre><p>This operator is particularly useful when dynamic type information is needed and for performing reflection operations on types.</p><h3>14- DEFAULT OPERATOR (default):</h3><p>The default operator returns the default value of the specified type. Default values are predefined by the software for each type:</p><ul><li>Numeric types: 0</li><li>Boolean: false</li><li>Textual types: null</li><li>Char: \0</li><li>Reference types: null</li></ul><p><em>For example:</em></p><pre>Console.WriteLine(default(int)); // outputs the default value for int, which is 0<br>Console.WriteLine(default(short)); // outputs the default value for short, which is 0</pre><p>It can also be used in assignments:</p><pre>int a = default; // assigns the default value, which is 0, to the variable a</pre><p>This operator is useful for obtaining and assigning default values dynamically and for scenarios where default values need to be explicitly specified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*FgjUmvRe8zBtnXRGYDXYXw.png" /></figure><h3>15- IS OPERATOR (is):</h3><p>The is operator is used to check the original type of a value subjected to boxing and returns a boolean result (true or false).</p><p>The is operator checks whether a value is of a specified type. If the value is of the specified type, it returns true; otherwise, it returns false.</p><ul><li><strong>Boxing and Unboxing:</strong> The operator is useful for determining the actual type of values that have undergone boxing (the process of converting value types to reference types).</li></ul><pre>object x = true; // boxing<br>Console.WriteLine(x is bool); // returns true</pre><pre>object y = 5; // boxing<br>Console.WriteLine(y is string); // returns false</pre><p>This operator is useful for checking type compatibility and performing type-checking operations.</p><h3>16- IS NULL OPERATOR (is null):</h3><p>The is null operator checks whether the value of a variable is null, returning true if it is, and false if it is not.</p><ul><li>If the variable’s value is null, is null returns true.</li><li>If the variable’s value is not null, it returns false.</li></ul><pre>string a = &quot;abcd&quot;;<br>string b = default;<br>Console.WriteLine(a is null); // returns false<br>Console.WriteLine(b is null); // returns true</pre><p><strong>Applicability:</strong> The is null operator can only be used with nullable types. Value types are not nullable by default, but with the ? (Nullable) operator, value types can be made nullable, allowing the is null operator to be used for them.</p><p>This operator is useful for checking whether variables are null and can help manage program behavior based on the presence or absence of values.</p><h3>17- IS NOT NULL OPERATOR (is not null):</h3><ul><li>It is used to determine if a variable’s value is not null. If the variable is not null, it returns true; otherwise, it returns false.</li></ul><pre>string a = &quot;abcd&quot;;<br>string b = default;<br>Console.WriteLine(a is not null); // returns true<br>Console.WriteLine(b is not null); // returns false</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*lY_m6pHLN4r3h2jpGjnDJw.png" /></figure><p><strong><em>Use with Nullable Types:</em></strong></p><ul><li>The is not null operator can only be used with nullable types. Value types (e.g., int, bool) cannot be null by default, but they can be made nullable with the ? (Nullable) operator, allowing the is not null operator to be used with them.</li></ul><p>This operator is useful for checking if a variable’s value is valid and managing program flow accordingly.</p><h3>18- AS OPERATOR (as):</h3><p>The as operator is an alternative to the cast operator for unboxing. Unlike the cast operator, it returns null instead of throwing a runtime error if the conversion is not possible.</p><ul><li><strong>Usage:</strong> The as operator can only be used with reference types. It cannot be used with value types.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*K61xUpPhtVxCAbmBwD-RHA.png" /></figure><p><strong>Value Types:</strong> The as operator cannot be used with value types (e.g., int, float). Attempting to use it with value types will result in a compilation error.</p><p><strong>Reference Types:</strong> The as operator works with reference types (e.g., string, object). If the cast is not possible, it returns null.</p><pre>object x = 111;<br>int y = x as int; // cannot be used with value types<br>string z = x as string; // returns null</pre><p>The as operator simplifies error management and control since it returns null instead of throwing an exception when the cast fails.</p><p>The as operator allows you to perform type conversions more safely and with better control. Unlike the cast operator, it returns null when the conversion is not possible, rather than throwing an exception.</p><h3>19- NULLABLE OPERATOR (?):</h3><p>In C#, value types (such as int, float) do not normally accept null values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*jRakUblFyh81AGq-ceV95A.png" /></figure><p>To make value types nullable, the ? operator is used. This operator allows the value type to accept null values. For example, int? represents a nullable integer type, and variables of this type can hold null values.</p><blockquote>int? nullableInt = null;</blockquote><p><em>For Example:</em></p><pre>int? a = null;</pre><p><strong>Operators Related to Null:</strong> Nullable value types can use is null, is not null, as, and other null-related operators. These operators enable null checks and conversions for nullable types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*xNFavtkRH_PbVlie6lHBrw.png" /></figure><p>In summary, by using the ? operator, you can make value types nullable and use various operators to handle null values with these types.</p><h3>20- NULL COALESCING OPERATOR (??):</h3><p>The ?? operator returns a different value if the given variable&#39;s value is null.</p><p><em>Example Usage:</em></p><pre>string a = null;<br>Console.WriteLine(a ?? &quot;Hello&quot;); // &#39;a&#39; null ise &quot;Hello&quot; yazdırır</pre><p>In this example, since a is null, the output will be &quot;Hello&quot;.</p><p><strong>Type Compatibility:</strong> Both sides of the ?? operator must be of the same type.</p><h3>21- NULL COALESCING ASSIGNMENT OPERATOR (??=):</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qWWDuxSY8vdyblOM_jPkpg.png" /></figure><p>The ??= operator works like the ?? operator but also assigns the provided value to the variable if it is null. If the variable is not null, no assignment occurs.</p><pre>string a = null;<br>Console.WriteLine(a ??= &quot;Hello&quot;); // outputs &quot;Hello&quot; and assigns it to &#39;a&#39;<br>Console.WriteLine(a); // outputs &quot;Hello&quot;</pre><p>In summary, the ??= operator is used for assigning a default value to variables that are null, making your code simpler and more compact.</p><blockquote><strong>Conclusion:</strong></blockquote><p><em>✨ Mastering operators in C# is key to writing effective and efficient code. From arithmetic and comparison operators to logical and assignment operators, each plays a critical role in manipulating data and controlling program flow. By understanding and utilizing these operators, you can enhance the functionality and performance of your applications.</em></p><p><em>We will dive deeper into these topics in our upcoming articles. Stay tuned for more C# insights and coding tips! ✨ Happy coding!</em></p><blockquote><strong>Acknowledgments:</strong></blockquote><p><em>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this post.⭐️</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deabbc90c89f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive into C# Type Conversions: Techniques and Best Practices]]></title>
            <link>https://medium.com/@eminy/understanding-type-conversions-in-c-d28ca17adbf9?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/d28ca17adbf9</guid>
            <category><![CDATA[implicit-conversion]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[explicit-conversion]]></category>
            <category><![CDATA[type-conversion]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 11:55:27 GMT</pubDate>
            <atom:updated>2024-07-31T22:32:30.427Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! In this post, we will explore how to perform type conversions in C#. Type conversions are essential for transforming data values from one type to another, enabling us to perform appropriate operations on the data. Understanding how and when to use type conversions can prevent errors and improve the efficiency of your code. Let’s dive in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*twimfYmtZpsirVEJG77STA.jpeg" /></figure><h3><strong>Type Conversions:</strong></h3><p>During the software development process, we may need to change the types of the values we work with. Type conversions allow us to perform operations that are suitable for the data’s inherent type. For example, if we have a numerical value stored as a string, such as string number = &quot;123&quot;, we can convert it to an int, bool, or char to perform type-appropriate operations on it.</p><p>When we receive values from different services and need to convert them to suitable types, type conversion becomes necessary.</p><p><strong><em>Important!</em></strong></p><p>The goal of type conversions is to transform the type of the data to a compatible one. Converting data to an incompatible type is not possible and will result in an error. To avoid errors, we must ensure that the target type is appropriate for the given data. For example:</p><ul><li>(String) &quot;123&quot; can be converted to int or decimal, but not to bool.</li><li>(String) &quot;Hilmi&quot; cannot be converted to int, bool, or char because the value is not compatible.</li><li>(String) &quot;a&quot; can only be converted to char.</li><li>(int) 123 can be converted to string or char, but not to bool.</li></ul><p>When performing type conversions, it is crucial to select a target type that is appropriate for the value’s type to avoid runtime errors.</p><p><strong>Now, let’s examine conversions based on types:</strong></p><h4><strong>Converting Textual Values to Other Types:</strong></h4><p>To convert a string value to a suitable type, we can use two methods: Parseand Convert.</p><blockquote><strong>Parse Function:</strong></blockquote><p>The Parse function is used to convert string values to the target type.</p><blockquote>Type x = type.Parse(…)</blockquote><p>Example:</p><pre>string y = &quot;123&quot;;<br>short z = short.Parse(y);<br><br>string maritalStatus = &quot;true&quot;;<br>bool _maritalStatus = bool.Parse(maritalStatus);</pre><blockquote><strong>Convert Functions:</strong></blockquote><p>The Convert functions are used to convert values to the target type. Unlike the Parse function, Convert is not limited to string types and can be used for any type.</p><pre>string x = &quot;123&quot;;<br>int _x = Convert.ToInt32(x);<br><br>string y = &quot;3.14&quot;;<br>double _y = Convert.ToDouble(y);</pre><h4>Converting Other Values to Textual Values:</h4><p>To convert a value to a string type, we can use either Convert or ToString.</p><blockquote><strong>Example with Convert:</strong></blockquote><pre>int a = 24;<br>string _a = Convert.ToString(a);</pre><blockquote><strong>ToString Function:</strong></blockquote><p>The ToString function is available for all types and can easily convert any type to a string.</p><pre>float f = 25;<br>string _f = f.ToString();</pre><h4>Converting Between Numerical Types:</h4><p>Numeric types may require different approaches when converting among themselves. These approaches are implicit type conversion and explicit type conversion.</p><blockquote><strong>Implicit Type Conversion</strong></blockquote><p>When a numerical value is converted to another type with a larger range, no additional steps are needed. This process is called <strong>implicit conversion</strong>.</p><p>Implicit type conversion is the process of converting a numeric value to another numeric type with a larger range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9EQCWMZA2inty1KETNf-UQ.png" /><figcaption>Implicit type conversion is the process of converting a numeric value to another numeric type with a larger range.</figcaption></figure><p><em>Example of Implicit Conversion:</em></p><pre>int a = 3000;<br>float f = a;  // Here, an implicit conversion occurs. The compiler automatically handles it.<br><br>short x = 123;<br>long y = x;</pre><blockquote><strong>Explicit Type Conversion</strong></blockquote><p>When converting a numerical value to a type with a smaller range, the target type may not be able to accommodate the value. Due to the risk of not fitting into the range of that type, this operation needs to be performed explicitly. This requires <strong>explicit conversion</strong> to handle the potential data loss.</p><figure><img alt="Explicit type conversion is the process of assigning a numeric value to a type with a smaller range. Due to the size mismatch, data loss is possible in this case." src="https://cdn-images-1.medium.com/max/1024/1*tqqS3y0DKY8Gr5I--z5LxA.png" /><figcaption>Explicit type conversion is the process of assigning a numeric value to a type with a smaller range</figcaption></figure><p><em>Example of Explicit Conversion:</em></p><pre>int x = 3000;<br>short y = (short)x;  // Here, explicit conversion using the cast operator occurs.<br><br>int x = 60000;<br>short _x = (short)x;  // Data loss occurs due to the smaller range of short type.</pre><p><strong>So, what happens if we convert a numeric type to its subtype, and the value does not fit into the range of the subtype?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bc24v57hrZqNZIguVfMuRg.png" /></figure><p>In such a case, data loss will occur. By data loss, we mean that if the value of an int type is 37000 and it is to be converted to a short type, the short type has a range of 256. In this case, the value 37000 will be repeatedly divided by 256, and the remainder will be the final value, with the rest being considered as data loss.</p><blockquote><strong>Handling Explicit Conversions with Checked and Unchecked:</strong></blockquote><p><strong>Checked:</strong> During explicit conversion, the checked keyword provides a control mechanism that alerts the developer at runtime if data loss is likely.</p><pre>checked<br>{<br>    int a = 9123;<br>    byte b = (byte)a;  // If data loss is possible, a runtime error is thrown.<br>}</pre><p><strong>Unchecked:</strong> The unchecked keyword ignores potential data loss and does not throw a runtime error. By default, code blocks are unchecked.</p><pre>unchecked<br>{<br>    int a = 9123;<br>    byte b = (byte)a;  // Veri kaybı olsa bile runtime&#39;da uyarı vermez.<br>}</pre><h4><strong>Converting Bool to Numerical Types:</strong></h4><p>When a boolean value is converted to a numerical type, it follows logical equivalence:</p><ul><li>true = 1</li><li>false = 0</li></ul><p><em>Example:</em></p><pre>bool b = true;<br>int i = Convert.ToInt32(b);  // i = 1<br><br>bool a = false;<br>double _a = Convert.ToDouble(a);  // _a = 0</pre><h4>Converting Numerical Types to Bool:</h4><pre>int i = 1;<br>bool b = Convert.ToBoolean(i);  // b = true<br><br>int i = 0;<br>bool b = Convert.ToBoolean(i);  // b = false<br><br>int i = 232;<br>bool b = Convert.ToBoolean(i);  // b = true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efnwDfnrWPwdkfVgrj9QhA.png" /><figcaption>ASCII TABLE</figcaption></figure><h4><strong>Converting Char to Numerical Types:</strong></h4><p>When converting a character to a numerical type, we use the ASCII code, where each character has a numerical equivalent.</p><p><em>Example:</em></p><pre>char a = &#39;a&#39;;<br>int _a = (int)a;  // Uses ASCII code</pre><h4><strong>Converting Numerical Types to Char:</strong></h4><p>We convert numerical values to their corresponding ASCII character.</p><pre>int o = 111;<br>int O = 79;<br><br>char _o = (char)o;  // _o = &#39;o&#39;<br>char _O = (char)O;  // _O = &#39;O&#39;</pre><blockquote><strong>Conclusion:</strong></blockquote><p><em>✨ I hope this article has helped you understand the various type conversions in C#. From converting strings to numbers and vice versa, to handling boolean and character conversions, mastering these techniques is crucial for effective coding. Stay tuned for more insights and tips on C# and .NET! ✨</em></p><p><strong>Acknowledgments:</strong></p><blockquote>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this post.⭐️</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d28ca17adbf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Your C# Skills: Understanding Synchronous and Asynchronous Execution]]></title>
            <link>https://medium.com/@eminy/boost-your-c-skills-understanding-synchronous-and-asynchronous-execution-b97c13efaf72?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97c13efaf72</guid>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[c-sharp-development]]></category>
            <category><![CDATA[synchronous]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 14:55:37 GMT</pubDate>
            <atom:updated>2024-07-26T14:55:37.386Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! In this post, we will explore how code execution works in C#. Specifically, we will delve into the differences between synchronous and asynchronous code execution. Understanding these concepts is crucial for writing efficient and responsive applications. Let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*7PV8tJSMg2Fe7o0IJdY6eA.png" /></figure><blockquote><strong>How Code Execution Works:</strong></blockquote><p><strong>There are two main types of code execution: synchronous and asynchronous.</strong></p><p><strong>Synchronous Execution:</strong> In synchronous execution, tasks are performed one after another. This means that a new task will not start until the current task is completed. At any given time t, the task being performed is well-defined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*fQSCqoM9wctYF9xQnjvO2g.png" /><figcaption><strong>Synchronous</strong></figcaption></figure><p><strong>Asynchronous Execution:</strong> In asynchronous execution, tasks can run in parallel. This means that multiple tasks can be performed at the same time, and calculating the exact state of tasks at any given time TT can be more complex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*3oS_uIk5G8M4enbARb1SOA.png" /><figcaption><strong>Asynchronous</strong></figcaption></figure><blockquote><strong>By default, code executes synchronously. For example:</strong></blockquote><pre>int a;<br>int b = 10;<br>string c = &quot;John&quot;;</pre><p>When this code is compiled, the program executes it synchronously, processing each line from top to bottom in sequence. One task must finish before moving on to the next.</p><h4>Now, let’s define what we mean by a “concept” in this context.</h4><p>When we write code, we structure it using statements. Each statement ends with a semicolon (;), indicating the end of that particular concept. In C#, code is processed concept by concept, not line by line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*droNsCQcT6-AMrA-fOJKAw.png" /></figure><p><strong>Conclusion:</strong> ✨ I hope this article helps you understand the fundamental differences between synchronous and asynchronous code execution in C#. Understanding these concepts is essential for developing efficient and responsive applications. Stay tuned for more insights and tips on C# and .NET! ✨</p><p><strong>Acknowledgments:</strong> This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this post.⭐️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97c13efaf72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive: Understanding Variables and RAM in C#]]></title>
            <link>https://medium.com/@eminy/deep-dive-understanding-variables-and-ram-in-c-3feb1f6d311c?source=rss-41575c567267------2</link>
            <guid isPermaLink="false">https://medium.com/p/3feb1f6d311c</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[c-sharp-language]]></category>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[c-sharp-developer]]></category>
            <dc:creator><![CDATA[eminy]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 11:17:19 GMT</pubDate>
            <atom:updated>2024-08-04T14:18:11.152Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! In this post, we will explore how data is managed within software using C#. This is a fundamental concept that underpins efficient software development and accurate data processing. By understanding how data resides in RAM and how variables function, you’ll gain a solid foundation for your programming journey. Let’s dive in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2X6sIoeLDwD-XVuNQFjcQg.png" /></figure><h3><em>1. Introduction to Data and RAM</em></h3><blockquote><strong>Where Does Data Reside in Software?</strong></blockquote><p>Our computers have a part called RAM (Random Access Memory), also known as temporary memory or cache. Data used during processing is kept in RAM. Similarly, in our software, we keep the data we will process in RAM.</p><blockquote><strong>RAM and Variables</strong></blockquote><p>RAM is divided into specific sections internally. Data is not stored in the software; instead, software keeps data in RAM. To store the data to be processed in RAM within software, variables are used.</p><h3><em>2. Variables in C#</em></h3><p>In C#, to store data in RAM, we first need to determine the types of the variables to be defined. When a specific area in RAM is allocated for a variable, it is called a value-type variable. Value-type variables store only one value, such as Name, Surname, or Age.</p><blockquote><strong><em>Primitive Types</em></strong></blockquote><p>Primitive types are the most basic types. For example, byte is a primitive type, but the decimal type made up of bytes is not primitive, though it is a value type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*3DMC6iYrgnKFRCv3KKI_VA.png" /></figure><blockquote><strong><em>Defining Variables</em></strong></blockquote><p>To store data in RAM, an appropriate area must be allocated based on the type of the variable. Before defining a variable, we need to create its model, that is:</p><blockquote>variable_type variable_name;</blockquote><p>First, the type of the variable is written, then a meaningful name is given to the variable, and finally, a semicolon is added to close the concept. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*QpemhMUVgNq_BaDSRE8vcQ.png" /></figure><p>After defining and compiling these, memory will be allocated for name and age.</p><blockquote><strong>Rules for Defining Variables</strong></blockquote><ul><li><strong>Meaningful Naming:</strong> Variable names should express the meaning of the value they hold.</li><li><strong>Special Character Usage:</strong> Naming should not contain special characters like ‘, ., ?, !. Only the _ character is an exception.</li><li><strong>Numeric Expressions:</strong> Variable names can contain numeric expressions but cannot start with a numeric expression. Also, within a scope, multiple variables with the same name cannot be defined.</li></ul><blockquote><strong>Naming Conventions</strong></blockquote><ul><li><strong>PascalCase:</strong> Each word’s first letter is uppercase. Example: NameSurname, UserName.</li><li><strong>camelCase:</strong> The first letter of all words except the first is uppercase. Example: salesStatus, orderId, userName.</li><li><strong>snake_case:</strong> All words are lowercase and separated by an underscore. Example: user_name, order_id.</li></ul><blockquote><strong>Using @ in Variable Naming</strong></blockquote><p>Programmatic keywords cannot be used as variable names. If a keyword needs to be used as a variable name, it can be overridden with the @ operator.</p><pre> string @static;<br> string @void;</pre><h3><em>3. Structure of RAM</em></h3><blockquote><strong>Stack and Heap</strong></blockquote><p>RAM is divided into two main sections: Stack and Heap.</p><ul><li><strong>Stack:</strong> The section where value-type variables and their values are stored. It works on a FIFO (First In First Out) basis.</li><li><strong>Heap:</strong> The section where objects can be stored.</li></ul><h3><em>4. Assigning Values to Variables</em></h3><blockquote><strong>Assigning Values to Defined Variables</strong></blockquote><p>Using the assign (=) operator, the value on the right is assigned to the variable on the left. Example:</p><pre> int age = 23; // Value assignment<br> string name = &quot;John&quot;;<br> char firstLetter = &#39;J&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jx6K-5mRHOWj0Epfd0D0hA.png" /><figcaption>C# Variables</figcaption></figure><p><strong><em>Textual Values</em></strong></p><p>Textual expressions are stored using the string keyword and written within double quotes. Example:</p><pre>string name = &quot;John&quot;;</pre><p><strong><em>Character Values</em></strong></p><p>Character expressions are stored using the char keyword and written within single quotes. Example:</p><pre>char firstLetter = &#39;J&#39;;</pre><p><strong><em>Logical Values</em></strong></p><p>Logical expressions are stored using the bool keyword and indicated with true or false. Example:</p><pre>bool single = true;<br>bool student = false;</pre><p><strong><em>Numeric Values</em></strong></p><p>Numeric expressions directly send the value. Structures like double quotes and single quotes are not used. Numeric expressions are assumed to be of int type by default if they are whole numbers. Decimal numbers are assumed to be of double type by default. Example:</p><pre>float pi = 3.14f;<br>double e = 2.71d;<br>decimal price = 9.99m;</pre><blockquote><strong>Assigning Values with Tuple Type</strong></blockquote><p>A tuple is an object that allows us to define multiple variables in a single syntax. Example:</p><pre>(int a, string b) tuple = (5, &quot;John&quot;);<br>Console.WriteLine(tuple.a); // 5<br>Console.WriteLine(tuple.b); // John</pre><blockquote><strong>Literal Formatting</strong></blockquote><p>Allows us to read numeric expressions more easily. Example:</p><pre>int number = 1_000_000;</pre><blockquote><strong>Assigning Default Values to Variable Types</strong></blockquote><p>The default keyword returns the default value of the specified type. Example:</p><pre>bool x = default;<br>int y = default;</pre><blockquote><strong>Reading the Value of a Defined Variable</strong></blockquote><p>To get the value of a variable, use the variable’s name.</p><p>Console.Writeline() -&gt; A method that allows us to print output to the console screen.</p><pre>int x = 5; <br>Console.WriteLine(x); // 5 <br>int y = x;</pre><blockquote><strong>Variables Without Values</strong></blockquote><p>Variables defined within a class are automatically assigned default values. However, for variables defined within the main method, a default value is not assigned, so we cannot perform operations on empty defined variables unless we manually assign an initial value as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*I3RT--2LACrUSSvPQqtbyg.png" /></figure><blockquote>To ensure the program is easily processable and codable, make it a habit to manually assign initial values to variables defined within a method.</blockquote><h3><em>5.Const and Readonly</em></h3><blockquote><strong>const Keyword</strong></blockquote><p><strong>const:</strong> Structures created to hold values that do not change and should not change. The existing value in the process cannot be changed; if attempted, the compiler will give an error. Defined with const. It comes from Constant.</p><ul><li>It does not change.</li><li>Essentially static.</li><li>Similar to variables in prototype but its value does not change once set.</li><li>When defining with const, the value must be given during the definition stage. Example:</li></ul><pre>const int DAYS_IN_WEEK = 7;</pre><blockquote><strong>readonly Keyword</strong></blockquote><p>Defines variables that are only readable. Unlike const, the value can be assigned not only where it is defined but also within the constructor. Additionally, readonly is not static unlike const. Example:</p><pre>readonly int myReadOnlyValue; <br>public MyClass() { myReadOnlyValue = 10; }</pre><h3><em>6. Assigning Values Between Variables</em></h3><p>When assigning values between variables, there are two behaviors: Deep copy and Shallow copy.</p><ul><li><strong><em>Deep Copy:</em></strong><em> </em>In deep copy, the data we have is duplicated and cloned. For value-type variables, deep copy is the default behavior.</li></ul><pre>int a = 5; <br>int b = a;</pre><ul><li><strong><em>Shallow Copy:</em></strong> Shallow copy is performed on reference-type variables. It means that multiple references in memory point to a single data. As a result, if the relevant value undergoes a change, this change will be reflected in all referencing variables.</li></ul><blockquote>Normally, value-type variables are deep copied by default. However, as we will see later in the medium article, shallow copy can be done for value-type variables using the ref keyword.</blockquote><h3><em>7. Scope and Accessibility</em></h3><blockquote><strong>Understanding Scope</strong></blockquote><p>Scope is the area that determines the accessibility limits of variables and functions. Scope is defined by { } curly braces. A variable defined within a scope is accessible everywhere within that scope after it is defined. Also, multiple variables with the same name cannot be defined within the same scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*BoUb6PazAWW9LLdQUKaMIw.png" /></figure><p>If a variable is defined in an outer scope, it can be accessed within nested scopes, but it cannot be accessed from a different scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*vIjOCb6BlcFWX03tBB4IQg.png" /></figure><blockquote><strong>Global Variables</strong></blockquote><p>If a variable is defined within the class scope, it is called a global variable.</p><h3><em>8. What is an Object?</em></h3><p>The object type can accommodate all types. Until now, we have used types like string, int, char, and bool. But objectsays: &quot;All these types derive from me.&quot; That is, all types are inherently derived from the object type. For example, since the string type is derived from the object type, the value &quot;John&quot; can be handled with object. Similarly, the integer value 5, being of int type, can be handled with object because it is derived from object. The object type is a reference-type variable but can also accommodate value-type variables. object variables store the relevant data in RAM as an object type but keep the data in its original type as well. This means the data within an object can be retrieved in its original type.</p><h4>Boxing</h4><p>Boxing is the process of sending a value of any type to an object type variable.</p><pre>int x = 5;<br>object y = x; // Boxing<br>y = 10;<br>Console.WriteLine(y); // 10</pre><p>In the above example, x directly allocates an area in RAM as an int type, meaning it stores the value 5 directly as an int. However, the variable y, which is received as an object, does not work the same way. The object type first creates an object and places an int type y variable inside it. As a result of boxing, the relevant value is stored within the object in its type. However, the y variable will now present the value 10 to us as an object type. Here, the value obtained from the object type cannot undergo operations specific to its type. For instance, if there is a numerical value, mathematical operations cannot be performed on it since it comes as an object.</p><h4>Unboxing</h4><p>To perform operations specific to the type of the value within an object variable, the value within the object must be obtained in its type. This process is called unboxing. This process is carried out using the Cast operator.</p><p><strong><em>Cast Operator</em></strong></p><p>It is an operator that allows us to obtain a boxed value in its own type, i.e., to perform unboxing. The Cast operator is in the form of ( ) and is used by writing the type of the object value within the parentheses and placing it to the left of the object variable we want to unbox. We use the ( ) operator by writing the inherent type of the object value inside it and unboxing the value by writing the variable to the right of the operator and assigning it to a variable of its type.</p><pre>object y = 10; // Boxing<br>int z = (int)y; // Unboxing</pre><blockquote>Important :</blockquote><p>The given value must be cast to the appropriate type. Otherwise, it will throw a runtime error.</p><h3><em>9. The var Keyword</em></h3><p>The var keyword is used to define a variable that suits the type of value being held. The var keyword assumes the type of the value assigned to it. The var keyword is automatically assumed by the compiler according to the type, but it is not a type itself. Its primary purpose is to serve as a common keyword to handle types not supported between different languages. It is used in integration between languages. When defining a variable with the var keyword, the value must be assigned during the definition stage because after determining and transforming into its type, it will behave as that type. After the initial value is assigned, the variable defined with the var keyword cannot be converted to different types.</p><blockquote><strong>Important Note:</strong> The difference between var and object is that var is a keyword, while object is a type. var transforms into the type of the assigned value, whereas object transforms the assigned value into object type by boxing.</blockquote><h3><em>10. The dynamic Keyword</em></h3><p>The dynamic keyword functions similarly to var, but while var transforms into the type of the value during compilation, dynamic does so at runtime. When first written, the type is not determined; thus, the dynamic keyword will determine the type at runtime but will not behave consistently. That is, it can change its type during runtime. It can accommodate data whose type is unknown at the time of definition.</p><blockquote><strong>Important Note:</strong> Data received from remote sources cannot be handled with the var keyword because the var keyword requires the value to be assigned at the time of definition.</blockquote><h3>Conclusion</h3><p>✨Understanding how RAM and variables operate in C# is fundamental for efficient software development. By managing data correctly and understanding the nuances of different types and keywords, we can write more reliable and performant code. This guide provides a comprehensive overview, but always remember to experiment and explore further to deepen your understanding.</p><p>We will explore these topics in greater depth in our upcoming articles. Stay tuned for more C# insights and coding tips! ✨ Happy coding!</p><h3>Acknowledgments</h3><blockquote>This article was inspired by the teachings of Gençay Yıldız. His insights and guidance have greatly influenced the content and direction of this writing. ⭐️</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3feb1f6d311c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>