<?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 hamed elsayed on Medium]]></title>
        <description><![CDATA[Stories by hamed elsayed on Medium]]></description>
        <link>https://medium.com/@hamedelsayediti32?source=rss-9c8caada59cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vfA8vCsBR3TZg_p_2YBV3w.jpeg</url>
            <title>Stories by hamed elsayed on Medium</title>
            <link>https://medium.com/@hamedelsayediti32?source=rss-9c8caada59cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:38:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamedelsayediti32/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# |Readonly and Constant]]></title>
            <link>https://medium.com/@hamedelsayediti32/c-readonly-and-constant-ea04834920d3?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea04834920d3</guid>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Wed, 21 Dec 2022 22:18:33 GMT</pubDate>
            <atom:updated>2022-12-21T22:18:33.007Z</atom:updated>
            <content:encoded><![CDATA[<h3>Constant</h3><p>A variable whose value can not be changed during the execution of the program.</p><p>which means we cannot assign values to the constant variable at run time. Instead, it must be assigned at the compile time.</p><h3>Readonly</h3><p>Readonly keyword is used to define a variable that can be assigned once after declaration, either during declaration or in the constructor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1295e250e467f6f398002ae8656a86f0/href">https://medium.com/media/1295e250e467f6f398002ae8656a86f0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea04834920d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C#| ?? and ??= Operators]]></title>
            <link>https://medium.com/@hamedelsayediti32/c-null-coalescing-operator-6cb57cd85968?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cb57cd85968</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Fri, 30 Sep 2022 13:17:29 GMT</pubDate>
            <atom:updated>2022-09-30T18:28:14.351Z</atom:updated>
            <content:encoded><![CDATA[<h3>C#| ?? and ??= Operators</h3><h3><strong>?? null-coalescing operator</strong></h3><p>The null-coalescing operator ?? returns the value of its left-hand operand if it isn&#39;t null; otherwise, it evaluates the right-hand operand and returns its result.</p><pre>x = y ?? z;</pre><p>In the example above, if ‘y’ is not null, then ‘x’ is set to ‘y’; however, if ‘y’ is null, then ‘x’ is set to ‘z’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce6d9bbb3bd9cf3f878f96d6468f9da4/href">https://medium.com/media/ce6d9bbb3bd9cf3f878f96d6468f9da4/href</a></iframe><p><strong>??= Null-coalescing assignment</strong></p><p>The null-coalescing assignment operator ??= assigns the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to null. The ??= the operator doesn&#39;t evaluate its right-hand operand if the left-hand operand evaluates to non-null.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6074a3fe44cb9261e48eb45bc9d2d773/href">https://medium.com/media/6074a3fe44cb9261e48eb45bc9d2d773/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cb57cd85968" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C# | String vs StringBuilder Memory Allocation]]></title>
            <link>https://medium.com/@hamedelsayediti32/c-string-vs-stringbuilder-memory-allocation-aa14a6dc7bd0?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa14a6dc7bd0</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[string-builder]]></category>
            <category><![CDATA[string]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Fri, 23 Sep 2022 12:25:30 GMT</pubDate>
            <atom:updated>2022-09-23T12:25:30.741Z</atom:updated>
            <content:encoded><![CDATA[<h3>StringBuilder Is used to represent a mutable string of characters.</h3><p>1-Mutable means the state of the object can be modified after it’s a declaration.<br>2-StringBuilder is provided by the StringBuilder class which is present in System.Text namespace.</p><p>3-It will not create a new modified instance of the current string object but do the modifications in the existing string object.</p><h3>String Is used to represent an Immutable string of characters.</h3><p>1- String class objects are immutable which means that if the user will modify any string object it will result into the creation of a new string object.<br>2-It makes the use of string costly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cm-1TzVLyoqp923Xowguug.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa14a6dc7bd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Restrict Special Characters From input Fields with Jquery]]></title>
            <link>https://medium.com/@hamedelsayediti32/restrict-special-characters-from-input-fields-with-jquery-8449b6801fa7?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8449b6801fa7</guid>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 13:31:36 GMT</pubDate>
            <atom:updated>2022-09-15T13:31:36.387Z</atom:updated>
            <content:encoded><![CDATA[<pre>$(&quot;#search&quot;).keypress(function(e) {<br> $(&quot;#error_msg&quot;).remove();<br> var k= e.keyCode,<br>   $return = ((k &gt; 64 &amp;&amp; k &lt; 91) || (k &gt; 96 &amp;&amp; k &lt; 123) || k == 8 || k == 32  || (k &gt;= 48 &amp;&amp; k &lt;= 57));<br>      if(!$return) {<br>       $(&quot;&lt;span/&gt;&quot;,{<br>         &quot;id&quot; : &quot;error_msg&quot;,<br>          &quot;html&quot;  : &quot;Special characters not allowed&quot;<br>        }).insertAfter($(this));<br>       return false;<br>      }<br>})</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8449b6801fa7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Argument Null Exceptions Before and at C# 10.0]]></title>
            <link>https://medium.com/@hamedelsayediti32/argument-null-exceptions-before-and-at-c-10-0-8e8a0f20332e?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e8a0f20332e</guid>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Fri, 09 Sep 2022 18:24:12 GMT</pubDate>
            <atom:updated>2022-09-09T18:28:27.434Z</atom:updated>
            <content:encoded><![CDATA[<h3>Null argument checks before C# 10.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DohqHooN41muZ5FxssULkA.png" /></figure><h3>Null argument checks in C# 10.0 and .NET 6.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sKQyVPINxvzxpJdXkvKSaQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e8a0f20332e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Switch Expression in C# 8.0]]></title>
            <link>https://medium.com/@hamedelsayediti32/switch-expression-in-c-8-0-553df77cf2cc?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/553df77cf2cc</guid>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 11:17:11 GMT</pubDate>
            <atom:updated>2022-09-03T11:17:11.799Z</atom:updated>
            <content:encoded><![CDATA[<p>In Switch expressions, all the cases are expressions so it’s a more ‘lightweight’ version. In the below code, anyone can analyze what exactly it is doing.</p><p>1- Example Using Switch Statment</p><pre>static void SwitchStatment()</pre><pre>{</pre><pre>int day = 4;</pre><pre>switch (day)</pre><pre>{</pre><pre>case 1:</pre><pre>Console.WriteLine(&quot;Monday&quot;);</pre><pre>break;</pre><pre>case 2:</pre><pre>Console.WriteLine(&quot;Tuesday&quot;);</pre><pre>break;</pre><pre>case 3:</pre><pre>Console.WriteLine(&quot;Wednesday&quot;);</pre><pre>break;</pre><pre>case 4:</pre><pre>Console.WriteLine(&quot;Thursday&quot;);</pre><pre>break;</pre><pre>case 5:</pre><pre>Console.WriteLine(&quot;Friday&quot;);</pre><pre>break;</pre><pre>case 6:</pre><pre>Console.WriteLine(&quot;Saturday&quot;);</pre><pre>break;</pre><pre>case 7:</pre><pre>Console.WriteLine(&quot;Sunday&quot;);</pre><pre>break;</pre><pre>default:</pre><pre>Console.WriteLine(&quot;no day found&quot;);</pre><pre>break;</pre><pre>}</pre><pre>}</pre><p>Same Example using Switch Expression</p><pre>static void SwitchExpression()</pre><pre>{</pre><pre>int day = 4;</pre><pre>var res = day switch</pre><pre>{</pre><pre>1 =&gt; &quot;Monday&quot;,</pre><pre>2 =&gt; &quot;Tuesday&quot;,</pre><pre>3 =&gt; &quot;Wednesday&quot;,</pre><pre>4 =&gt; &quot;Thursday&quot;,</pre><pre>5 =&gt; &quot;Friday&quot;,</pre><pre>6 =&gt; &quot;Saturday&quot;,</pre><pre>7 =&gt; &quot;Sunday&quot;,</pre><pre>_ =&gt; &quot;no day found&quot;,</pre><pre>};</pre><pre>Console.WriteLine(res);}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=553df77cf2cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hangfire Introduction and Implementation in .NET Core 6 Web API]]></title>
            <link>https://medium.com/@hamedelsayediti32/hangfire-introduction-and-implementation-in-net-core-6-web-api-65959b753d77?source=rss-9c8caada59cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/65959b753d77</guid>
            <dc:creator><![CDATA[hamed elsayed]]></dc:creator>
            <pubDate>Tue, 30 Aug 2022 23:40:44 GMT</pubDate>
            <atom:updated>2022-09-03T12:37:14.313Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hangfire Introduction and Implementation in .NET Core 6 Web API</h3><p><strong>What is Background Process?</strong></p><p>A process that runs behind the scenes without user intervention.</p><p><strong>Hangfire</strong></p><p>An easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required</p><p><strong>Why Background Processing?</strong></p><ul><li>Sometimes we need to do lengthy operations like database Operations</li><li>Batch import from XML, JSON, and YAML files.</li><li>Invoices generation.</li><li>Recurring monthly reports.</li><li>Automatic Subscription Renewal.</li><li>Sending Mail Notification Upon Sign up.</li></ul><p><strong>Prerequisites</strong></p><ul><li>Basic understanding of .NET Core 6 API and C#.</li><li>Visual Studio 2022</li><li>SQL Server</li></ul><h4><strong>Why Using Hangfire?</strong></h4><p>1- <strong>Reliable &amp; Persistent</strong></p><p>Once a background job was created, Hangfire takes the responsibility to process it</p><p><strong>2- Transparent &amp; Distributed</strong></p><p>Hangfire dashboard and more processing are added.</p><p><strong>There are different types of jobs that are present in Hangfire</strong></p><p><strong>Fire-and-Forget Job:</strong></p><p>Fire and Forget jobs are executed <strong>only once</strong> and almost <strong>immediately</strong> after creation.</p><p><strong>Delayed Job:</strong></p><p>A delayed job is executed <strong>only once</strong> too, but not immediately, after a certain <strong>time interval</strong>.</p><p><strong>Recurring Job:</strong></p><p>Recurring Jobs fire <strong>many times</strong> on the specified <strong>CRON schedule (Time Interval)</strong>.</p><p><strong>Continuations Job:</strong></p><p>The continuation job is executed when its parent job is executed and finished.</p><p><strong>Setting up Development Environment</strong></p><p>Step 1)</p><p>Open Visual Studio 2022 and create a new .NET Core Web API Project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Nie1Buze-D1Jq12HbA2xQ.png" /></figure><p>Step 2)</p><p>Provide the Project name HangFireBackGroungTask</p><p><strong>Step 3</strong></p><p>Also, provide additional information like .NET Framework 6, Configure HTTPS, and enable Open API support and swagger</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74ejb8dCDLbpOnKj7Qurdg.png" /></figure><p><strong>Step 4</strong></p><p>Install Hangfire NuGet Package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybdSySaDjwB26wMoBXQ-tg.png" /></figure><p><strong>Step 5</strong></p><p>Let’s configure things in Program.cs</p><pre>using Hangfire;<br>var builder = WebApplication.CreateBuilder(args);</pre><pre>builder.Services.AddHangfire(x =&gt; x.UseSqlServerStorage(builder.Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));</pre><pre>// Add the processing server as IHostedService</pre><pre>builder.Services.AddHangfireServer();</pre><pre>// Add services to the container.</pre><pre>builder.Services.AddControllers();</pre><pre>// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle</pre><pre>builder.Services.AddEndpointsApiExplorer();</pre><pre>builder.Services.AddSwaggerGen();</pre><pre>var app = builder.Build();</pre><pre>// Configure the HTTP request pipeline.</pre><pre>if (app.Environment.IsDevelopment()){</pre><pre>app.UseSwagger();</pre><pre>app.UseSwaggerUI();</pre><pre>}</pre><pre>app.UseHttpsRedirection();</pre><pre>app.UseAuthorization();</pre><pre>app.UseHangfireDashboard(&quot;/dashboard&quot;);</pre><pre>app.MapControllers();</pre><pre>app.Run();</pre><p><strong>Step 6</strong></p><p>Create API Controller and name it as HangFireController</p><pre>using Hangfire;</pre><pre>using Microsoft.AspNetCore.Mvc;<br>namespace HangFireBackGroungTask.Controllers</pre><pre>{</pre><pre>[Route(&quot;api/[controller]&quot;)]</pre><pre>[ApiController]</pre><pre>public class HangFireController : ControllerBase</pre><pre>{</pre><pre>[HttpGet]</pre><pre>[Route(&quot;login&quot;)]</pre><pre>public string Login()</pre><pre>{</pre><pre>//Fire - and - Forget Job - this job is executed only once</pre><pre>var jobId = BackgroundJob.Enqueue(() =&gt; SendMessage(&quot;Welcome to our app!&quot;));</pre><pre>return $&quot;Job ID: {jobId}. Welcome mail sent to the user!&quot;;</pre><pre>}</pre><pre>[HttpGet]</pre><pre>[Route(&quot;ProductOffer&quot;)]</pre><pre>public String ProductOffer()</pre><pre>{</pre><pre>//Delayed Job - this job executed only once but not immedietly after some time.</pre><pre>var jobId = BackgroundJob.Schedule(() =&gt; SendMessage(&quot;Welcome to our app&quot;), TimeSpan.FromSeconds(20));</pre><pre>return $&quot;Job ID: {jobId}. offer e-mail will be sent after 20 seconds!&quot;;</pre><pre>}</pre><pre>[HttpGet]</pre><pre>[Route(&quot;DailyOffers&quot;)]</pre><pre>public string DailyOffers()</pre><pre>{</pre><pre>//Recurring Job - this job is executed many times on the specified cron schedule</pre><pre>RecurringJob.AddOrUpdate(() =&gt; SendMessage(&quot;Sent daily offer&quot;), Cron.Daily);</pre><pre>return &quot;offer sent!&quot;;</pre><pre>}</pre><pre>[HttpGet]</pre><pre>[Route(&quot;productpayment&quot;)]</pre><pre>public string ProductPayment()</pre><pre>{</pre><pre>//Fire and Forget Job - this job is executed only once</pre><pre>var parentjobId = BackgroundJob.Enqueue(() =&gt; SendMessage(&quot;You have done your payment successfully!&quot;));</pre><pre>//Continuations Job - this job executed when its parent job is executed.</pre><pre>BackgroundJob.ContinueJobWith(parentjobId, () =&gt; Console.WriteLine(&quot;Product receipt sent!&quot;));</pre><pre>return &quot;You have done payment and receipt sent on your mail id!&quot;;</pre><pre>}</pre><pre>[ApiExplorerSettings(IgnoreApi = true)]</pre><pre>public void SendMessage(string message)</pre><pre>{</pre><pre>//write your bussiness logic</pre><pre>Console.WriteLine($&quot;message : {message}&quot;);</pre><pre>}</pre><pre>}}</pre><p><strong>Step 7</strong></p><p>Now, after you run the application, this swagger window will open, and using this we will perform operations one by one after hitting API endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-33N8mpYY--J6mThCwsyQ.png" /></figure><p>Also, it will create the following tables in the database related to Hangfire to manage jobs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*8frOx7YBjLR_Mlw9WLUlGA.png" /></figure><p><strong>Step 8</strong></p><p>You can now also open the Hangfire dashboard to manage background running jobs after hitting</p><p>The same API port in another window <a href="https://localhost:7298/dashboard">https://localhost:7298/dashboard</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CDgqfdsePkpGVvvMT8ZAuA.png" /></figure><p>Now we are going to execute API endpoints one by one and check newly created jobs in the Hangfire dashboard you can show also the execution method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-a4gCD8SHGLMKqL1YDfMpA.png" /></figure><p>Here, in Hangfire Dashboard you can see all the details about jobs like succeeded, scheduled, failed, and processing as I have shown in the above images.</p><p>Now we hit another endpoint ProductOffer and it will schedule one background job and execute once after a specified time interval</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojm58n5957Nly1amNi4M6Q.png" /></figure><p>Finally, we are going to hit our last API endpoint and check how recurring job is executed one by one</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5CyUjfGj5B-C2yl2H2fpyQ.png" /></figure><p>Here you can see how recurring job is created and executed one by one after a specific time interval.</p><p><em>Thank you</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65959b753d77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>