<?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 Stasoz on Medium]]></title>
        <description><![CDATA[Stories by Stasoz on Medium]]></description>
        <link>https://medium.com/@stasoz?source=rss-e30bf1e3bd94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ms_AHOvk2BQjEZsU0-9QMA.jpeg</url>
            <title>Stories by Stasoz on Medium</title>
            <link>https://medium.com/@stasoz?source=rss-e30bf1e3bd94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:35:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stasoz/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[How do I stay productive?]]></title>
            <link>https://stasoz.medium.com/how-do-i-stay-productive-abb0497f9cec?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/abb0497f9cec</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[mental-health]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 19:29:35 GMT</pubDate>
            <atom:updated>2024-07-01T19:29:35.990Z</atom:updated>
            <content:encoded><![CDATA[<p>Я давно начал изучать тему продуктивности, поскольку хочу максимально эффективно использовать свое время.</p><p>Ниже, я поделюсь своими 10 принципами, которые проверены годами и помогают мне оставаться продуктивным изо дня в день.</p><h4>1. Plan your day</h4><p>Самое важное это то, что ты хочешь сделать сегодня. Для этого нужно иметь четкое представление какие задачи ты будешь решать и для этого нужно их записывать, чтобы не забыть.</p><p>Можно записывать задачи на день в To-Do листах, для этого существует множество приложений, например я предпочитаю записывать все.</p><p>После каждой выполненной задачи я вычеркиваю соответсвующий пункт в списке и это мне приносит маленькое удовольствие от того что я смог сделать :)</p><p>Также, я предпочитаю составлять список дел в конце рабочего дня на следующий день. Я пытался составлять список дел в начале рабочего дня, но бывали такие дни, когда я просто терялся от тех задач, которые хочу выполнить и на планирование уходило слишком много времени. Поэтому я делаю это перед сном, когда никуда не спешу и расслаблен.</p><h4>2. Morning sets the mood for the whole day</h4><p>Я замечал по себе что когда я просыпался утром и сразу брал телефон и залипал в нем по 20–30 минут, это существенно снижало мою продуктивность и я мог ходить ленивым весь день и это жутко раздражало меня.</p><p>Затем я начал эксперементировать и построил свой утренний ритуал, который бодрит меня и дарит мне настроение на весь день:</p><ol><li>Как только я проснулся, я выпиваю стакан воды. Организму нужна жидкость с утра, поскольку за ночь он обезвожился.</li><li>Делаю медитация и зарядку на 5–10 минут. betterme</li><li>Занимаюсь спортом, каждый день по разному — бег, спортзал, йога. Для меня спорт очень важен, ведь большую часть дня я мало двигаюсь, поэтому выбираю активные виды спорта</li><li>Читаю минимум 30 минут</li><li>Готовлю завтрак с душой</li><li>После этого я готов покорять этот день</li></ol><p>Поэтому, я хочу посоветовать вам выстроить свой утренний ритуал. Пробуйте, экспериментируйте, подстраивайте утро так как вам это удобно, главное провести его для себя.</p><p>Если не верите, что утро это действительно золотая пора, то прочитайте книгу — The Miracle Morning (реферальная ссылка).</p><h4>3. Difficult tasks first</h4><p>Сложные задачи я стараюсь решить в первой половине дня, поскольку после обеда у меня уже пропадает та концентрация и активность мышления, которая была с утра.</p><p>Может у других людей наоборот — голова лучше работает вечером, но не у меня. Поэтому легкую и рутинную работу я оставляю на вторую половину дня.</p><h4>4. Comfortable workplace</h4><p>Я считаю что рабочее место должно вдохновлять на работу и создание чего-либо. Поэтому я стараюсь держать свое рабочее место в чистоте, поскольку когда я вижу что вокруг все на своих местах, то это переносится и на мое мышление, я мыслю чисто и ясно.</p><p>Также не жалейте денег и обустраивайте комфорт вокруг рабочего пространства, вы можете создать свой собственный уютный уголок.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uKY4jm5Yu_9cXgMyu3QJKQ.jpeg" /><figcaption>pixabay photostock</figcaption></figure><p>Посмотрите на рабочее место на картинке, разве оно не вдохновляет?</p><h4>5. Minimize distractions</h4><p>Общеизвестный факт — наш мозг способен эффективно решать лишь что-то одно за раз. Происходит это следующим образом: когда мы работаем над большой интеллектуальной задачей (пишем статью, программу, разрабатываем проект), то она захватывает всю рабочую (оперативную) память мозга.</p><p>Я приведу в пример ситуацию, которая наверное случалась с каждым. Допустим вы делаете задачу в которую погрузились с головой и вдруг вам приходит сообщение, вы отвлекаетесь на мгновение, чтобы прочитать его и затем снова возвращаетесь к задаче. Казалось бы, что тут такого? Но на самом деле на эти простые и незаметные нам действия мозг тратит колоссальное количество энергии.</p><p>В этот момент мозгу нужно переместить весь информационный контекст задачи, в которую вы погрузились до этого, из рабочей памяти в промежуточную (чтобы не произошло путаницы между двумя задачами), извлечь из вашей долгосрочной памяти сведения, необходимые для ответа на сообщение, поместить их в рабочую память и быть сосредоточенным снова.</p><p>Когда вы прочитали и ответили на сообщение мозгу нужно снова переключится к первоначальной задаче и поменять контекст.</p><p>Если так переключаться очень часто, то к обеду уже может закончиться запас энергии и вы вероятнее всего будете испытывать стресс из-за того что ничего не успели сделать.</p><p>Я решаю эту проблему следующим образом:</p><ol><li>Предупреждаю коллег, что буду временно недоступен;</li><li>Выключаю телефон и убираю его подальше;</li><li>Выключаю все мессенджеры;</li><li>Включаю легкую музыку и погружаюсь в работу;</li></ol><p>Иногда бывает, что звуки извне мешают сосредоточиться, для решения этой проблемы у меня есть наушники — sony wx4 1000 (ссылка), которые обладают супер шумоизоляцией и качественным звуком, рекоммендую тем, кому нужна абсолютная тишина.</p><h4>6. 45/15</h4><p>Я работаю по принципу 45/15, что это значит? 45 минут работы и 15 минут отдыха.</p><p>Во время время работы, я отключаю все мессенджеры, уведомления и т.д, то есть полностью погружаюсь в работу, а в перерывах я могу отвечать на сообщения, пойти сделать кофе или порастягиваться, в общем отдохнуть от работы.</p><p>Естественно, вы можете придумать свою схему работы и перерывов, например 50/10 или 60/15, это должно быть комфортно для вас, чтобы вы не уставали и успевали отдыхать.</p><h4>7. Reward yourself</h4><p>Выберите то, что вам нравится и что вы не позволяете себе делать постоянно: покупайте вкусную еду, выходите на кофе с друзьями, устраивайте походы в кино. Главное, чтобы этот ритуал был. Тогда вы почувствуете завершенность проекта, и это даст вам силы и стимул двигаться к новому.</p><h4>8. Meditation</h4><p>Я привык медитировать с утра и перед сном, но также могу и посередине дня, если есть какая-то задача, которую я не могу решить. Медитация помогает мне “перезагрузить” голову и придумать новое нестандартное решение.</p><p>К тому же медитация это один из самых верных способов управлять вниманием в течение дня. Через пару месяцев регулярной практики вы заметите разницу в способности концентрироваться, во внутренней ясности и продуктивности</p><h4>9. Sport</h4><p>Спорт позволяет не только держать тело в тонусе, но и хорошо перезагружает голову.</p><p>Поэтому с утра перед работой я люблю позаниматься спортом, чтобы проснуться и настроиться на день, а также после трудового дня сделать легкую пробежку чтобы компенсировать сидячую работу.</p><p>Так что выбирайте ваш любимый вид спорта и занимайтесь им 2–3 раза в неделю и вы почувствуете больше энергии и мотивации.</p><h4>10. Food affects productivity (imho)</h4><p>Я не диетолог и это лично мое наблюдение, но то что я ем напрямую влияет на мое настроение и продуктивность. Я полностью исключил из своего рациона быстрые углеводы, сладкое, мясо животного происхождения и животное молоко. Я перестал делать перекусы и начал питаться 3 раза в день и придерживаюсь пищевого окна 8/16 (например, начинаю первый прием пищи в 10 утра, а последний в 6 вечера).</p><p>Одна из моих любимых книг по питанию, которая открыла мне глаза — How not to die. Советую почитать, так как я уверен, что мы то что мы едим.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abb0497f9cec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How do I stay productive?]]></title>
            <link>https://blog.devgenius.io/how-do-i-stay-productive-18f602f71979?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/18f602f71979</guid>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Thu, 28 Apr 2022 13:45:52 GMT</pubDate>
            <atom:updated>2022-04-28T19:23:26.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJoMfVgbHoJyZI210IXGgg.jpeg" /><figcaption>Made by <a href="https://unsplash.com/@fakurian">Milad Fakurian</a>. Found on <a href="https://unsplash.com/">unsplash</a></figcaption></figure><p>I started studying productivity a long time ago, because I want to make the most of my time.</p><p>Below, I will share my 10 principles that have been proven over the years and help me stay productive day in and day out.</p><h4>1. Plan your day</h4><p>The most important thing is what you want to do today. To do this, you need to have a clear idea of ​​​​what tasks you will solve, therefore you need to write them down so as not to forget.</p><p>I prefer to write down my tasks in a notepad rather than in apps. Because this way I can concentrate more on my thoughts and not be distracted.</p><p>There are even separate notepads for this, just look:</p><ul><li><a href="https://amzn.to/3F3NpoM">Carson Dellosa Aim High To Do List Notepad</a></li><li><a href="https://amzn.to/3EVrSye">Knock Knock This Week Pad</a></li><li><a href="https://amzn.to/3vnghF1">Graphique Library Card To-Do List Notepad</a></li></ul><p>After each completed task, I cross off the corresponding item in the list and this brings me a little pleasure from what I was able to do 😊</p><p>Also, I prefer to make a to-do list at the end of the working day on the next day. I tried to make a to-do list at the beginning of the work day, but there were days when I just got lost in the tasks that I wanted to complete and it took too much time to plan. So I do it before bed, when I’m not in a hurry and relaxed.</p><h4>2. Morning sets the mood for the whole day</h4><p>I notice for myself that when I woke up in the morning, and immediately took the phone and got stuck in it after 20–30 minutes, it significantly affected my productivity, and I could walk around lazy all day, and it terribly annoyed me.</p><p>Then I started experimenting and built my own morning ritual that invigorates me and puts me in the mood for the whole day:</p><ol><li>As soon as I wake up, I drink a glass of water. During the night, the body has managed to dehydrate, so in the morning you need to replenish the water supply;</li><li>I do meditation and exercises for 10–20 minutes;</li><li>I go in for sports, every day in different ways — running, gym, yoga. Sport is very important for me, because most of the day I move little, so I choose active sports;</li><li>I read at least 30 minutes;</li><li>Make a breakfast;</li><li>After that I’m ready to conquer this day;</li></ol><p>Therefore, I want to advise you to build your morning ritual. Try, experiment, adjust the morning as it suits you, the main thing is to spend it for yourself.</p><p>If you do not believe that morning is really a golden time, then read the book — <strong>“</strong><a href="https://amzn.to/3vxJrBL"><strong>The Miracle Morning</strong></a><strong>”</strong>.</p><h4>3. Difficult tasks first</h4><p>I try to solve complex tasks in the first half of the day, because after lunch I already lose the concentration and activity of thinking that I had in the morning.</p><p>Maybe for other people, on the contrary, the head works better in the evening, but not for me. Therefore, I leave light and routine work for the second half of the day.</p><h4>4. Comfortable workplace</h4><p>I believe that the workplace should inspire to work and create something. Therefore, I try to keep my workplace clean, because when I see that everything around is in its place, this is transferred to my thinking, I think more clearly.</p><p>Also, do not spare money and arrange comfort around the workspace, you can create your own cozy corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSJSZacp4HHlasSt-JvePw.jpeg" /><figcaption>Made by Linus Mimietz. Found on <a href="https://unsplash.com/">unsplash</a></figcaption></figure><p>Look at the workplace in the picture, isn’t it inspiring?</p><h4>5. Minimize distractions</h4><p>It’s a well-known fact that our brain can only effectively solve one thing at a time. This happens as follows: when we are working on a large intellectual task (writing an article, a program, developing a project), it captures the entire working (operative) memory of the brain.</p><p>I will give an example of a situation that probably happened with everyone. Let’s say you’re doing a task that you’ve dived into and suddenly you get a message, then you’re distracted for a moment to read it and back to the task. What’s the big deal? But in fact, the brain spends a huge amount of energy on these simple and imperceptible actions.</p><p>At this point, the brain needs to move the entire informational context of the task you have been immersed in so far from working memory to intermediate memory (so that there is no confusion between the two tasks), extract from your long-term memory the information necessary to respond to the message, place it in working memory and be focused again.</p><p>When you have read and responded to the message, the brain needs to switch back to the original task and change the context.</p><p>If you switch like this very often, then by lunchtime your energy supply may already run out and you will most likely be stressed because you did not have time to do anything.</p><p>I solve this problem like this:</p><ul><li>I warn colleagues that I will be temporarily unavailable;</li><li>I turn off my phone and put it away;</li><li>I turn off all messengers;</li><li>I turn on light music and immerse myself in work;</li></ul><p>Sometimes it happens that external sounds interfere with concentration, to solve this problem I have headphones — <a href="https://amzn.to/3KneEvy"><strong>Sony WH-1000XM4 Wireless</strong></a>, which have super noise isolation and high-quality sound. I really recommend it to those who need absolute silence.</p><h4>6. 45/15</h4><p>I work 45/15, what does that mean? 45 minutes of work and 15 minutes of rest.</p><p>During work, I turn off all instant messengers, notifications, etc. That is, I completely immerse myself in work, and during breaks I can answer messages, go make coffee or stretch, in general, take a break from work.</p><p>Naturally, you can come up with your own scheme of work and breaks, for example 50/10 or 60/15, this should be comfortable for you so that you do not get tired and have time to rest.</p><h4>7. Reward yourself</h4><p>Choose what you like and what you don’t allow yourself to do often: buy delicious food, go out for coffee with friends, go to the movies. The main thing is that this ritual should be.</p><p>This ritual will give a sense of completion of a difficult task or project and give strength to conquer the next.</p><h4>8. Meditation</h4><p>I am used to meditating in the morning and before bed, but I can also meditate in the middle of the day if there is some problem that I cannot solve. Meditation helps me “reboot” my head and come up with a new non-standard solution.</p><p>In addition, meditation is one of the surest ways to manage attention throughout the day. After a couple of months of regular practice, you will notice a difference in the ability to concentrate, in inner clarity and productivity.</p><h4>9. Sport</h4><p>Sport allows not only to keep the body in good shape, but also reboots the head well.</p><p>Therefore, in the morning before work, I like to go in for sports in order to wake up and tune in to the day, and also after a hard day to do a light jog to compensate for sedentary work.</p><p>So choose your favorite sport and do it 2–3 times a week and you will feel more energized and motivated.</p><h4>10. Food affects productivity (imho)</h4><p>I am not a nutritionist and this is my personal observation, but what I eat directly affects my mood and productivity. I completely eliminated fast carbohydrates, sweets, meat of animal origin and animal milk from my diet. I stopped snacking and started eating 3 meals a day and stick to an 8/16 eating window (i.e. start my first meal at 10am and my last meal at 6pm).</p><p>One of my favorite nutrition books that opened me eyes is <a href="https://amzn.to/3vqhc7X"><strong>“How not to die”</strong></a>. I advise you to read, because I am sure that we are what we eat.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18f602f71979" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/how-do-i-stay-productive-18f602f71979">How do I stay productive?</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.13 Loops]]></title>
            <link>https://stasoz.medium.com/2-13-loops-6a5aa232d70c?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a5aa232d70c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 14:05:24 GMT</pubDate>
            <atom:updated>2022-12-19T08:01:31.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QvcOWgLS90HbpKrOeIC2vQ.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Loops allow you to execute a block of code repeatedly until a certain condition is met. C# has four different kinds of loops (for, while, do…while and foreach).</p><h3>Loop For</h3><p>Syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6af16a3c20375655cbc137575a900f5/href">https://medium.com/media/a6af16a3c20375655cbc137575a900f5/href</a></iframe><p><strong>initializer — </strong>is an expression that is calculated before the first execution of the loop body. Usually a local variable is declared here, which is a counter in the loop, but you can also declare other variables depending on the task.</p><p><strong>condition — </strong>this is an expression that is checked before each new iteration of the loop, if it is <strong>true</strong>, the iteration starts running, if not then the loop stops running.</p><p><strong>iterator</strong> — expression evaluated after each iteration. Iteration it is a one-time execution of a loop block. Usually, the value of the counter is incremented here.</p><p>Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8cc34231ead8ed45b13370f686ae520/href">https://medium.com/media/b8cc34231ead8ed45b13370f686ae520/href</a></iframe><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*XahsYZLVAA2-LX_SG8ji9Q.png" /></figure><p>Let’s see how the cycle works, step by step:</p><ol><li>Define variable int i = 1;</li><li>Add a loop condition, i ≤ 3, since this is the first iteration and i = 1, then the condition 1 ≤ 3 is true and the first iteration of the loop is started — a construct Console.WriteLine(i) that outputs the value of i to the console.</li><li>After executing the block of code, the first iteration ends and the third part of the loop is executed — i++. After that, the variable i will be equal to 2.</li><li>The condition i ≤ 3 is checked again. It is true (because 2 is less than or equal to 3), so the loop block is executed again — Console.WriteLine(i).</li><li>After executing the block of code, the second iteration ends and the third part of the loop is executed — i++. After that, the variable i will be equal to 3.</li><li>The condition i ≤ 3 is checked again. It is true (because 3 is less than or equal to 3), so the loop block is executed again — Console.WriteLine(i).</li><li>After executing the block of code, the third iteration ends and the third part of the loop is executed — i++. After that, the variable i will be equal to 4.</li><li>The condition i ≤ 3 is checked again. It is false (because 4 is NOT less than or equal to 3), so the loop terminates execution.</li></ol><p>You can also omit the first and third part of the loop, the main thing is not to forget to put a semicolon:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/886fe3124b00dcaf47e865b20d2fb213/href">https://medium.com/media/886fe3124b00dcaf47e865b20d2fb213/href</a></iframe><p>Result will be the same as in example above, because we have exactly the same loop exit condition and a counter variable i that is declared outside the loop which is incremented with each iteration.</p><p>And if we do not specify the condition for exiting the loop, then we get an infinite loop:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dd7e317159c778c64e2286062c25ab9/href">https://medium.com/media/2dd7e317159c778c64e2286062c25ab9/href</a></iframe><p>Finally, consider the example with several variables in the declaration of the loop:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7893f9c11c19273c773bc93f9d12e88/href">https://medium.com/media/f7893f9c11c19273c773bc93f9d12e88/href</a></iframe><p>First we define two variables i = 1 and j = 1 at the beginning of the loop, then add a loop exit condition i &lt; 5 and specify that after each iteration, the value i and j incremented.</p><p>Inside the loop, we output the current iteration and the result of multiplying i by j<strong>.</strong></p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*jj4sPCLAbmfE2jRXY_Yb_w.png" /></figure><h3>Loop While</h3><p>In a <strong>while</strong> loop, the condition is executed first, then the code execute if the condition is <strong>true</strong>. <strong>while</strong> is similar to <strong>for</strong> but includes only condition. Syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50d08bf231d49d17a5c18a768f2d74cd/href">https://medium.com/media/50d08bf231d49d17a5c18a768f2d74cd/href</a></iframe><p>Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0391a90f63150d115919cefb47f82b1b/href">https://medium.com/media/0391a90f63150d115919cefb47f82b1b/href</a></iframe><p>Here we declare a variable i, which will be checked in the while loop condition and decrease with each iteration until the condition becomes false.</p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*mPkED9fQnFWyXHkF1GyG3w.png" /></figure><h3>Loop do…while</h3><p>The <strong>do…while</strong> loop in C# is the post-test version of <strong>while</strong> loop. This means that the loop condition is checked after the loop body is executed. Syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d683bac93ba206ad23533f0fb19ecd20/href">https://medium.com/media/d683bac93ba206ad23533f0fb19ecd20/href</a></iframe><p>The <strong>do…while</strong> loop should be used when you need to execute the code inside the loop at least once. Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d795d5548d0902965ad2bc3818ab025/href">https://medium.com/media/8d795d5548d0902965ad2bc3818ab025/href</a></iframe><p>Although we have a variable i less than 0, the loop will still be executed once.</p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*rhhaIN7ZQpMHZQXrDWfDaA.png" /></figure><h3>Loop foreach</h3><p><strong>foreach</strong> loop is used to iterate over an array or collection of elements. Syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b1acf87fd025c1fbf42047706d026cd/href">https://medium.com/media/2b1acf87fd025c1fbf42047706d026cd/href</a></iframe><p>Here, <strong>data_type variable</strong> means the type and name of the loop variable that receives element value of the <strong>collection</strong> at each iteration and <strong>collection</strong> represents the collection/array for iteration.</p><p><strong>foreach</strong> works as follows — at the beginning of the loop, the first element of the collection is assigned to the loop variable, after each iteration, the following collection element is assigned to a loop variable. The loop runs until it goes through all the elements of the collection.</p><p>Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b91e24207f79728f3d5e19abe06702b/href">https://medium.com/media/0b91e24207f79728f3d5e19abe06702b/href</a></iframe><p>Here the collection is the string — “Hello”, because string is an array of characters. So we’re going to go through every string character. We also declared a variable item in the loop with a type char that must match to the type of collection elements.</p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*zkB5cg11_MZep75S0WxU4g.png" /></figure><p>We can also explicitly not specify the type of variable in the loop, but use the keyword <strong>var</strong>. In the case of using <strong>var</strong>, the compiler will determine the type itself. In practice, var is most often used than explicit type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a63a686e814c8eee65118d2acd93b45/href">https://medium.com/media/9a63a686e814c8eee65118d2acd93b45/href</a></iframe><p>We have looked at how to iterate over a string in a <strong>foreach</strong>, but in the next sections, we’ll get to know arrays and collections and look at how to iterate over them.</p><h3>Nested loops</h3><p>Loops can be nested in others loops, I will show this with the example of a <strong>for</strong> loop:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/371a97c8d15902272b63944c3825567f/href">https://medium.com/media/371a97c8d15902272b63944c3825567f/href</a></iframe><p>Here the loop for (int i = 1; i &lt;= 4; i++) has 4 iterations, but within each iteration, another loop for (int j = 1; j &lt;= 5; j++) is executed with 5 iterations.</p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*LLFBvVM9m1ivJgKe1Ie9VA.png" /></figure><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/6196ccc4db73">2.12 Ternary operator</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9ySR3KoUGqGpTtE.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a5aa232d70c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.12 Ternary operator]]></title>
            <link>https://stasoz.medium.com/2-12-ternary-operator-6196ccc4db73?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/6196ccc4db73</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Sat, 23 Apr 2022 06:27:13 GMT</pubDate>
            <atom:updated>2022-12-19T08:01:20.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdj-P0x0aI83aSjunri_qg.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Another conditional statement that allows you to control the flow of the program is ternary operator. Syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e408adaaf74ced2f1dfa6661c26ff8e/href">https://medium.com/media/2e408adaaf74ced2f1dfa6661c26ff8e/href</a></iframe><p>There are three operands here. In the condition, we pass bool value. If the condition is true, then the statement1 is executed, otherwise statement2 is executed. Example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f46f20c772eef91b5781dfe02e7c8db2/href">https://medium.com/media/f46f20c772eef91b5781dfe02e7c8db2/href</a></iframe><p>Here we have a condition number1 &gt; number2 which returns <strong>true</strong> or <strong>false.</strong> If the condition is <strong>true</strong>, then the value after the question mark (?) will be written to the result variable, otherwise value after colon (:).</p><p>Does anything remind you of a ternary operator? It’s a <strong>if/else</strong> statement🙂.</p><p>So the ternary operator is just shorthand for if/else. Example above using if/else looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d621c3210ffbd2682d1f7ab71a89b4f3/href">https://medium.com/media/d621c3210ffbd2682d1f7ab71a89b4f3/href</a></iframe><p>Here we did without the result variable, but the ternary operator returns a value and it must be written to a variable.</p><h3>Nested Ternary Operator</h3><p>The ternary operator can be nested, as well as <a href="https://medium.com/p/edd142af43e2">if/else statements</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8af0cf586dbab65886b2a1a5f63f9763/href">https://medium.com/media/8af0cf586dbab65886b2a1a5f63f9763/href</a></iframe><p>With if/else statements, we could write it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/046708040fdab85e5ea2741f8dfda7dc/href">https://medium.com/media/046708040fdab85e5ea2741f8dfda7dc/href</a></iframe><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/edd142af43e2">2.11 if else Statements</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-13-loops-6a5aa232d70c">2.13 Loops</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZG8zMVGlnxWvN1nQ.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6196ccc4db73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.11 if else Statements]]></title>
            <link>https://stasoz.medium.com/2-11-if-else-statements-edd142af43e2?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/edd142af43e2</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Sat, 23 Apr 2022 06:13:49 GMT</pubDate>
            <atom:updated>2022-12-19T08:01:10.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIYu6pqstKMCFVIO5Q8sIw.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Before you start reading, I want to ask you to like this article, so I will know that my work helps you ❤️</p><p>Conditional statements allow you to control the flow of program execution to not execute every line of code as it should be in the program.</p><p>For this in C# there are several statements, now we will consider <strong>if/else. if/else</strong> statements check the condition, which must return <strong>bool</strong> value and depending on the check, a particular code section is executed. Syntax<strong>:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ec5a157c3bce002647867960983f8e3/href">https://medium.com/media/9ec5a157c3bce002647867960983f8e3/href</a></iframe><h3>if statement</h3><p>After the if keyword must be specified condition that return <strong>bool</strong> value:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d025024dcca8a749951b1ba07ad402e3/href">https://medium.com/media/d025024dcca8a749951b1ba07ad402e3/href</a></iframe><p>In the example above, if the number1 &gt; number2 will return true<strong>,</strong> then condition will be met.</p><p>If our block contains one construction, we can write it as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99122cdd5dfa9dc5910976c7a98b404f/href">https://medium.com/media/99122cdd5dfa9dc5910976c7a98b404f/href</a></iframe><p>But if the block contains more than one construction, it is necessary to write with brackets {}:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be167d58992e1c4f9289404a1f90cbb5/href">https://medium.com/media/be167d58992e1c4f9289404a1f90cbb5/href</a></iframe><p>We can also put more complex conditions in the check, but conditions must return bool value:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37d2389242805d4d9abc91a836e5a4b2/href">https://medium.com/media/37d2389242805d4d9abc91a836e5a4b2/href</a></iframe><h3>else if statement</h3><p>What if we want to add another check, for example, if the number2 greater than the number1? Then we can use the <strong>else if</strong> statement:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2334d1b710785ba4b77d53fa1200dcd3/href">https://medium.com/media/2334d1b710785ba4b77d53fa1200dcd3/href</a></iframe><p>Above the first check will return false because 10 is not greater than 15 and the program will jump to <strong>else if</strong> which return true (10 &lt; 15)<strong>.</strong></p><p><strong>Else if</strong> blocks can be created as many as you need, depending on your tasks, but once one of the conditions is met, the next checks will not be performed!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c98cc053e2df0716bac360169bfce9bd/href">https://medium.com/media/c98cc053e2df0716bac360169bfce9bd/href</a></iframe><h3>else statement</h3><p>Well, what if no condition is met and we want to react on that somehow? For this you need <strong>else</strong> statement. It must be placed at the end, after <strong>if</strong> and <strong>else if</strong> statements and the code in it is executed if none of the above conditions worked:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68e920fe9ae2a3514d46ec7afe7e487f/href">https://medium.com/media/68e920fe9ae2a3514d46ec7afe7e487f/href</a></iframe><p>Remember that example above can be written in short form:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/941dfb611b97ffdd454dc703e26f46cb/href">https://medium.com/media/941dfb611b97ffdd454dc703e26f46cb/href</a></iframe><h3>Nested if/else/else if statements</h3><p>It’s also good to know that all conditional statements can be nested:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2be8ff42870454420b082c244873f77d/href">https://medium.com/media/2be8ff42870454420b082c244873f77d/href</a></iframe><p>Sometimes nested statements are useful and sometimes they complicate the code. Try not to overuse nested constructs and make the code as clear and short as possible.</p><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/aafccff5d01c">2.10 Operators Precedence and Associativity</a></p><p>Next article -&gt; <a href="https://medium.com/@stasoz/2-12-ternary-operator-6196ccc4db73">2.12 Ternary operator</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gPWMZP_SWOcRtMZD.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edd142af43e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.10 Operators Precedence and Associativity]]></title>
            <link>https://stasoz.medium.com/2-10-operators-precedence-and-associativity-aafccff5d01c?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/aafccff5d01c</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 13:14:15 GMT</pubDate>
            <atom:updated>2022-12-19T08:01:00.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XTtoJXe9CLcgxe1R0Jx1Gg.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Before you start reading, I want to ask you to like this article, so I will know that my work helps you ❤️</p><p>Before summarising Operators Precedence and Associativity, I would like to say that there are Bitwise and shift operators. In practice, they are used very rarely and I don’t think you will be needing them in the beginning, so I did not write about them and will not include them in the summary, but you can always read about them in the official documentation — <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#logical-and-operator-">Bitwise and shift operators</a> and now let’s return to the summarising.</p><p>Each operator has its own precedence and operators with highest precedence are executed first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86cbd898d6412f0de6675abe773c57fa/href">https://medium.com/media/86cbd898d6412f0de6675abe773c57fa/href</a></iframe><p>Here, the multiplication operation has a higher precedence than addition, so it is performed first. But with parentheses, we could change the order of operations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be9b165e87d5c9ecead91b9f1b1986c3/href">https://medium.com/media/be9b165e87d5c9ecead91b9f1b1986c3/href</a></iframe><p>Also, if two operators have the same precedence, then the order of calculation is determined by associativity. As you remember from previous section <a href="https://medium.com/p/2c8bd46eed60">Arithmetic Operators</a>, there are two types of operators:</p><ul><li>Left-associative operators that execute from left to right;</li><li>Right-associative operators that execute from right to left;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2338c97ad1e8f08a13fbac002edb5da0/href">https://medium.com/media/2338c97ad1e8f08a13fbac002edb5da0/href</a></iframe><h4>Table of Operators Precedence and Associativity</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gTc0pc8Z47Qtx0bPSrrM_Q.png" /></figure><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/359aa02a47b9">2.9 Logical Operators</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-11-if-else-statements-edd142af43e2">2.11 if else Statements</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a coffee</a>. I send all donations to support the army of Ukraine.</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lviQAsrtgJB0dMiercB9ig.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aafccff5d01c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.9 Logical Operators]]></title>
            <link>https://stasoz.medium.com/2-9-logical-operators-359aa02a47b9?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/359aa02a47b9</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Sat, 16 Apr 2022 12:55:38 GMT</pubDate>
            <atom:updated>2022-12-19T08:00:50.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0X_o4m6RX9WkSz_z5CR4w.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Before you start reading, I want to ask you to like this article, so I will know that my work helps you ❤️</p><p>Logical Operators accept bool values as operands and return bool.</p><ul><li>&amp;&amp; — Conditional logical AND operator. If both operands are true, returns true, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/689d3a853cd7e101493ef6181bc5af1d/href">https://medium.com/media/689d3a853cd7e101493ef6181bc5af1d/href</a></iframe><ul><li>|| — Conditional logical OR operator. If one of the operands is true, returns true, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ff843e2adeac5b952b1aa0967c069d9/href">https://medium.com/media/1ff843e2adeac5b952b1aa0967c069d9/href</a></iframe><ul><li>! — Logical negation operator. Performed on a single operand and returns true if the operand is false and vice versa.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/149d3f1ed888e1865bc4c0bc94788bd6/href">https://medium.com/media/149d3f1ed888e1865bc4c0bc94788bd6/href</a></iframe><p>Summary — Operators Precedence and Associativity (Article in progress)</p><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/684c51ed6db8">2.8 Comparison Operators</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-10-operators-precedence-and-associativity-aafccff5d01c">2.10 Operators Precedence and Associativity</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a coffee</a>. I send all donations to support the army of Ukraine.</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lviQAsrtgJB0dMiercB9ig.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=359aa02a47b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.8 Comparison Operators]]></title>
            <link>https://stasoz.medium.com/2-8-comparison-operators-684c51ed6db8?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/684c51ed6db8</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Wed, 06 Apr 2022 18:26:50 GMT</pubDate>
            <atom:updated>2022-12-19T08:00:21.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdYArqq3dBBdYRVQnC6C8Q.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Comparison operators are used to compare two operands and return <strong>bool</strong> value (true or false).</p><ul><li><strong>==</strong> — Equal to. If both operands are equal, returns <strong>true</strong>, otherwise <strong>false .</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9e40138da3c1f047b164dfd43e64dc1/href">https://medium.com/media/c9e40138da3c1f047b164dfd43e64dc1/href</a></iframe><ul><li><strong>!=</strong> — Not equal. If operands are not equal, returns true, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88bd442fafe4ea53f15dcd7c53159b36/href">https://medium.com/media/88bd442fafe4ea53f15dcd7c53159b36/href</a></iframe><ul><li><strong>&gt; </strong>— Greater than. Returns true if the first operand is greater than the second, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53b34b4279e7b1cb7a6abc82459d969b/href">https://medium.com/media/53b34b4279e7b1cb7a6abc82459d969b/href</a></iframe><ul><li><strong>&lt;</strong> — Less than. Returns false if the first operand is less than the second, otherwise true.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06c4b2e7966e086cf9522a199b29660c/href">https://medium.com/media/06c4b2e7966e086cf9522a199b29660c/href</a></iframe><ul><li><strong>&gt;=</strong> — Greater than or equal to. Returns true if the first operand is greater than or equal to the second, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/828a3615210b84a29e35e0ae1195d1d6/href">https://medium.com/media/828a3615210b84a29e35e0ae1195d1d6/href</a></iframe><ul><li><strong>&lt;=</strong> — Less than or equal to. Returns true if the first operand is less than or equal to the second, otherwise false.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb7dabf739f7b75f096ff0e344960d96/href">https://medium.com/media/eb7dabf739f7b75f096ff0e344960d96/href</a></iframe><p><a href="https://stasoz.medium.com/2-10-operators-precedence-and-associativity-aafccff5d01c">Summary — Operators Precedence and Associativity</a></p><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/ad1500c49a5c">2.7 Assignment Operators</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-9-logical-operators-359aa02a47b9">2.9 Logical Operators</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6PqktVGlXnRntlzQ.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=684c51ed6db8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.7 Assignment Operators]]></title>
            <link>https://stasoz.medium.com/2-7-assignment-operators-ad1500c49a5c?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad1500c49a5c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 11:08:51 GMT</pubDate>
            <atom:updated>2022-12-19T08:00:04.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4drmmYd1peJIJrG3NKLKeA.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Assignment operators set the value of the right operand to the left operand. The most basic assignment operator that is found everywhere is <strong>=</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f0313fb2ce54cffd2edc6b9b69e767f/href">https://medium.com/media/5f0313fb2ce54cffd2edc6b9b69e767f/href</a></iframe><p>Here, using the operator <strong>=</strong> we set the value of the age variable. Also, you can simultaneously assign a value to several variables at once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e764e91fce07dd502bf9004eaabc547/href">https://medium.com/media/8e764e91fce07dd502bf9004eaabc547/href</a></iframe><p><strong>=</strong> — is right-associative operator, it means that first initializes z, then y, then x<strong>. </strong>Let’s consider other assignment operators:</p><ul><li><strong>+=</strong> — addition assignment; Same as x = x + 5;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7ad2b0c3804ce5008d1f0f267764cb8/href">https://medium.com/media/e7ad2b0c3804ce5008d1f0f267764cb8/href</a></iframe><ul><li><strong>-=</strong> — subtraction assignment; Same as x = x — 4;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fa32ffe1b6102eb80732a3c5e6f0588/href">https://medium.com/media/2fa32ffe1b6102eb80732a3c5e6f0588/href</a></iframe><ul><li><strong>*=</strong> — multiplication assignment; Same as x = x * 3;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f08687aeb6d092f90fe0773715b5009/href">https://medium.com/media/7f08687aeb6d092f90fe0773715b5009/href</a></iframe><ul><li><strong>/=</strong> — division assignment; Same as x = x / 2;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6dfcac6e476a3f3e1e539c3510b53e25/href">https://medium.com/media/6dfcac6e476a3f3e1e539c3510b53e25/href</a></iframe><ul><li><strong>%=</strong> — modulo assignment; Same as x = x % 5;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e13412068c561e51af8df9d904a97635/href">https://medium.com/media/e13412068c561e51af8df9d904a97635/href</a></iframe><p>Of course, C# has more assignment operators, but we’ll look at them later so you know how to use them.</p><p><a href="https://stasoz.medium.com/2-10-operators-precedence-and-associativity-aafccff5d01c">Summary — Operators Precedence and Associativity</a></p><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://medium.com/p/2c8bd46eed60">2.6 Arithmetic Operators</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-8-comparison-operators-684c51ed6db8">2.8 Comparison Operators</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X7IkaqILpt22lOGq.png" /></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li><li>Unknown — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad1500c49a5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2.6 Arithmetic Operators]]></title>
            <link>https://stasoz.medium.com/2-6-arithmetic-operators-2c8bd46eed60?source=rss-e30bf1e3bd94------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c8bd46eed60</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Stasoz]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 11:54:42 GMT</pubDate>
            <atom:updated>2022-12-19T07:59:56.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXQgvhjAajO77_KJY9qL2w.png" /></figure><p>You can check this course on <a href="https://itifico.com/courses/view/638dfcf65408a9c17fe87da2/638dfdce5408a9c17fe87da9/C%20Intro">my website</a>.</p><p>Operations represent certain actions over operands (variables) involved in the operation.</p><p>Operations can be binary — performed on two operands, unary — performed on a single operand, ternary — performed on three operands.</p><h3>Binary arithmetic operations:</h3><ul><li><strong>+</strong> — addition, adds the right operand to the left;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65d8f5c543aecc6cb0b1619d53f8a1b4/href">https://medium.com/media/65d8f5c543aecc6cb0b1619d53f8a1b4/href</a></iframe><ul><li><strong>-</strong> — subtraction, subtracts the right operand from the left;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a6bf2ae2d2282c777d84a901bb2fb57/href">https://medium.com/media/3a6bf2ae2d2282c777d84a901bb2fb57/href</a></iframe><ul><li><strong>*</strong> — multiplication, multiplies the left and right operand;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e395cfb3130be421a84df017617ee95/href">https://medium.com/media/4e395cfb3130be421a84df017617ee95/href</a></iframe><ul><li><strong>/</strong> — division, divides the left operand by the right. Division by zero is prohibited, otherwise you will get <strong>DivideByZeroException</strong>;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20b125b54e92ad039bedbd28ce5f8934/href">https://medium.com/media/20b125b54e92ad039bedbd28ce5f8934/href</a></iframe><p>When dividing, keep in mind that if both operands represent integers, then the result will also be rounded to an integer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f473eeeefe0acf8e238a13f7dcb4518b/href">https://medium.com/media/f473eeeefe0acf8e238a13f7dcb4518b/href</a></iframe><ul><li><strong>%</strong> — modulus, returns the remainder after dividing the left operand by the right;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/001c7719936a73bef3088fa83bca9fb6/href">https://medium.com/media/001c7719936a73bef3088fa83bca9fb6/href</a></iframe><h3>Unary arithmetic operations:</h3><ul><li><strong>++</strong> — increment. The increment can be <strong>pre-fixed</strong>: ++x — first, the value of x is incremented by 1, and then its value is returned as the result of the operation. Also, increment can be <strong>post-fixed:</strong> x++ — first, the value of x is returned as the result of the operation, and then 1 is added to it:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbc10dc9a45a73bdd03e8363c46eefc2/href">https://medium.com/media/cbc10dc9a45a73bdd03e8363c46eefc2/href</a></iframe><ul><li><strong>- -</strong>— decrement. Decreases the value of the operand by one, can also be pre-fixed and post-fixed:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82ee1ee79f0d6753e1ecc0e721bf9deb/href">https://medium.com/media/82ee1ee79f0d6753e1ecc0e721bf9deb/href</a></iframe><p>So we looked at binary and unary operations. What happens if we write it like this?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a7e15fdf5d7b4fd0683c4070e2091f9/href">https://medium.com/media/9a7e15fdf5d7b4fd0683c4070e2091f9/href</a></iframe><p>Confused, right? Fortunately, C# has operator precedence. Precedence of arithmetic operations from highest to lowest:</p><ul><li>increment, decrement;</li><li>multiplication, division, modulus;</li><li>addition, subtraction;</li></ul><p>Now ready to answer the example above? Order of operations:</p><ol><li>Post-increment (x = 19)</li><li>Multiplication (y * z = 12)</li><li>Subtraction (19–12 = 7)</li></ol><p>Answer — 7.</p><p>For convenience, it could be written like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac842fb2dde218c29a7eb7a37cb8e112/href">https://medium.com/media/ac842fb2dde218c29a7eb7a37cb8e112/href</a></iframe><p>But with parentheses, we could change the order of operations, for example, as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a4a092ff1cf816206decc18e3fbf1da/href">https://medium.com/media/0a4a092ff1cf816206decc18e3fbf1da/href</a></iframe><p>Think about the answer here, then you can check yourself via Visual Studio, just run code there and write output to the console or use <a href="https://medium.com/@stasoz/1-4-debugging-7cdde0b5f097">breakpoint</a>.</p><h3>Operator associativity</h3><p>As we said, multiplication and division operations have the same precedence. So what’s the result will be here?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/042911a9210bf4104c73e29ddde3a944/href">https://medium.com/media/042911a9210bf4104c73e29ddde3a944/href</a></iframe><p>When operations have the same precedence, the order of calculation is determined by associativity. Depending on associativity, there are two types of operators.</p><ul><li>Left-associative operators that execute from left to right (Postfix Increment and Decrement, Multiplication, Division, Modulus, Additive);</li><li>Right-associative operators that execute from right to left (Prefix Increment and Decrement Operators);</li></ul><p>So, the result above will be 75, because multiplication and division operators are left associative.</p><p>After you go through all the operators, then you can check <a href="https://stasoz.medium.com/2-10-operators-precedence-and-associativity-aafccff5d01c">an article with the precedence and associativity of each operator</a>, as a summary.</p><p><a href="https://stasoz.medium.com/c-10-and-net-6-contents-c5d04d04c65f">Contents</a></p><p>Previous article -&gt; <a href="https://stasoz.medium.com/2-5-console-input-output-fda73f712ae6">2.5 Console Input/Output</a></p><p>Next article -&gt; <a href="https://stasoz.medium.com/2-7-assignment-operators-ad1500c49a5c">2.7 Assignment Operators</a></p><p>Join to our community in Telegram — <a href="https://t.me/itifico">https://t.me/itifico</a></p><p>If you want to support me, you can <a href="https://www.buymeacoffee.com/stasoz">buy me a cup of coffee</a> and I will drink it when I write the next article :)</p><figure><a href="https://www.buymeacoffee.com/stasoz"><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y2CbkTT9CO1FdH-f.png" /></a></figure><p>Donations list:</p><ol><li>Dinesh Chintalapudi — 3$</li><li>Unknown — 5$</li><li>Neisy — 3$</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c8bd46eed60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>