tag:blogger.com,1999:blog-30962715916685506212024-03-13T06:35:38.591-07:00CoDebateDebating Code - [ASP.NET, C#, Sql Server, VB.NET]Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-3096271591668550621.post-41811632987647239442018-03-28T02:39:00.001-07:002018-03-28T02:39:32.575-07:00C# - 'yield' keyword (Kenneth Truyers)There are so many least-used facilities are still out there within C#. '<i>Yield</i>' keyword is one such thing!<br />
<br />
When searched for learning, I have been getting a lot of examples however most of the examples use '<i>static</i>' keyword too! Feeling <i>static </i>as irrelevant in this case, I was looking for examples <i>without </i>it.<br />
<br />
Later, I came across a wonderful article and would like the readers to go-through it :
<a href="https://www.kenneth-truyers.net/2016/05/12/yield-return-in-c/">Kenneth-Truyers - 'yield' keyword!</a>. Thanks to Kenneth (Microsoft MVP) for throwing a good light on this topic!<br />
<br />
A gist from his article : (Courtesy : <a href="https://www.kenneth-truyers.net/" target="_blank">Kenneth Truyers</a>)<br />
<br />
<ul>
<li>Yield retains the state of the iteration. (without having to use <i>static </i>keyword or additional collections)</li>
</ul>
<ul>
<li>Yield returns a placeholder of list (<i>IEnumerable<t></t></i>) to the client promising that it would give list of elements <b>on-demand</b>.</li>
</ul>
<ul>
<li>Yield gives the ability to <i>defer </i>execution. This is evident from his second example.</li>
</ul>
<br />
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~<br />
<i>Thanks for visiting! Happy Programming :)</i><br />
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~<br />
<br />Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com0tag:blogger.com,1999:blog-3096271591668550621.post-77597793554197998552009-12-13T03:12:00.000-08:002018-03-28T02:41:32.606-07:00Code Challenges (SQL Server)Challenges are really great in the sense of personal and professional improvement.<br />
<br />
<span style="font-weight: bold;">BeyondRelational</span> - one kind of raising and solving Challenges for <span style="font-weight: bold;">Microsoft Sql Server</span> Developers. <br />
<br />
Please check this in here..<br />
<span style="font-weight: bold;">http://beyondrelational.com/blogs/tc/default.aspx</span><br />
<br />
What they do actually ?<br />
Well, they raise a problem which should be solved by a SQL Server queries.<br />
Of those Challenges, which might have many other rules and conditions, the main rule might be - to write a <span style="font-weight: bold;">single query</span> for complex problems.<br />
<br />
Happy Challenging !!!Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com0tag:blogger.com,1999:blog-3096271591668550621.post-18552923589041569412009-10-24T00:15:00.000-07:002009-10-24T00:52:47.891-07:00Importing MS Project Plan (.mpp) Data in ASP.NETIf you are struggling with Native libraries to import mpp (MSProject Plan) file data, this article is for you. This is written after my personal experience.<br /><br />In the beginning , I used MSProject (InterOp) assemblies and a demo version of MSProject for my development. The problem I faced is the license. Like my other Office Automation Efforts(not recommended by MS because of its inconsistency), this assembly demands a MS Project Installation and a license in my machine.<br /><br />So, I was placed in a chance to search of alternative methods. I got <span style="font-weight: bold;">MPXJ</span>, a Java-based Free Open Source library which has extensive collections of methods and utilities in it to read enough an mpp data. This pack also comes with JVM library as it needs for its compilation.<br /><br />Functions,shown below, are the some of the useful things and will return a <span style="font-style: italic;">List object</span>.<br /><span style="font-style: italic;">task.getResourceNames()</span><br /><span style="font-style: italic;">resource.getTaskAssignments()</span><br /><span style="font-style: italic;">resourceassignment.getPeakUnits()</span><br /><br /><span style="font-weight: bold;">Download MPXJ: http://mpxj.sourceforge.net/<br /><br /><span style="color: rgb(0, 0, 153);">Happy Programming !!! </span><br /></span>Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com2tag:blogger.com,1999:blog-3096271591668550621.post-27273091555281063202009-10-08T09:51:00.000-07:002009-10-15T12:15:07.220-07:00A Great Spark from Microsoft - WebsiteSpark<blockquote style="font-weight: bold; font-family: georgia;"><span style="color: rgb(51, 51, 255);">Microsoft announces WebsiteSpark for Web Portal Owners !!!</span><br /><br /><span style="font-weight: normal;">With every offer announced by other commercial products, there may be little </span><br /><div style="text-align: justify;"><span style="color: rgb(0, 0, 153);">* Condition Apply</span><span style="font-weight: normal;"> tag appear to declare a <span style="font-style: italic;">Win-Lose</span> chance in which usually customer is the loser. But MS announces a <span style="font-style: italic;">Win-Win</span> chance for website owners to make their portals still in .NET environment.<span style="font-weight: bold;"></span></span><br /></div><br /><span style="font-weight: normal;">When more and more open source software users increased, it is Microsoft's turn to bring back the Website Owners and Deployers to Microsoft's Native Platform for their commercial portals and corporate sites. </span><br /><br /><span style="font-weight: normal;">What a .NET developer would prefer to develop and deploy portals in .NET Technologies, a Website Owner would prefer to use Open Source Database such as MySQL, etc, as it costs nothing.</span><br /><br />So, actually what is WebsiteSpark?<br /><br /><span style="font-weight: normal;">Last Month, ScottGu of MS announces the WebsiteSpark program, which holds a couple of <span style="font-weight: bold;">free development and production licenses</span> in the .NET Platform for the <span style="font-weight: bold;">three </span>years.</span><br /><br /><span style="font-weight: normal;">The free licenses include:</span><br /><span style=";font-size:85%;" ><ul style="font-weight: normal;"><li>3 licenses of Visual Studio 2008 Professional Edition </li><li>1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web) </li><li>2 licenses of Expression Web 3 </li><li>4 processor licenses of Windows Web Server 2008 R2 </li><li>4 processor licenses of SQL Server 2008 Web Edition </li><li>DotNetPanel control panel (enabling easy remote/hosted management of your servers) </li></ul><span style="font-weight: normal;">MS believes giving them at no cost encourages the use of .NET deployment environment </span><br /><br /></span><span style=";font-size:85%;" ><h3><span style="font-size:100%;"><u>What happens after the 3 years?</u></span></h3><h3><span style="font-weight: normal;font-size:100%;" >Still there is no compulsion to continue with the same licenses. But if the user would like to continue, then he has to pay a minimum amount of about Rs.10000/Yr.</span></h3>For more details:<br />http://www.microsoft.com/web/websitespark/<br />http://weblogs.asp.net/scottgu/archive/2009/09/24/announcing-the-websitespark-program.aspx</span></blockquote>Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com0tag:blogger.com,1999:blog-3096271591668550621.post-34922858993228270532009-07-01T10:22:00.001-07:002009-07-03T10:01:36.213-07:00Strange Behavior of NULL Values in SQL Queries<p>I found a strange behavior of NULL Values when I have a table values as in the following: </p> <!-- code formatted by http://manoli.net/csharpformat/ --> <pre class="csharpcode"><span class="kwrd">Declare</span> @val <span class="kwrd">table</span><br />(<br />Id <span class="kwrd">int</span>,<br />Username <span class="kwrd">varchar</span>(100),<br />Desg <span class="kwrd">varchar</span>(100),<br /><span class="kwrd">Level</span> <span class="kwrd">varchar</span>(100)<br />) <br /><br /><span class="kwrd">Insert</span> <span class="kwrd">into</span> @val<br /><span class="kwrd">select</span> 1,<span class="str">'AAA'</span>,<span class="kwrd">NULL</span>,1 <span class="kwrd">union</span> <span class="kwrd">all</span><br /><span class="kwrd">select</span> 1,<span class="str">'BBB'</span>,<span class="kwrd">NULL</span>,1 <span class="kwrd">union</span> <span class="kwrd">all</span><br /><span class="kwrd">select</span> <span class="kwrd">NULL</span>,<span class="str">'CCC'</span>,<span class="str">'SE'</span>,1 <span class="kwrd">union</span> <span class="kwrd">all</span><br /><span class="kwrd">select</span> 2,<span class="kwrd">NULL</span>,<span class="str">'PL'</span>,4 <span class="kwrd">union</span> <span class="kwrd">all</span><br /><span class="kwrd">select</span> 2,<span class="str">'EEE'</span>,<span class="kwrd">NULL</span>,5<br /><br /><span class="rem">-- Query 1 </span><br /><span class="kwrd">select</span> * <span class="kwrd">from</span> @val <br /><br /><span class="rem">-- Query 2 </span><br /><span class="kwrd">select</span> Id,Username,desg,<span class="kwrd">COUNT</span>(*)<br />[<span class="kwrd">No</span>. <span class="kwrd">of</span> Employees] <span class="kwrd">from</span> @val<br /><span class="kwrd">where</span> desg <> <span class="str">'SE'</span><br /><span class="kwrd">group</span> <span class="kwrd">by</span> Id,Username,Desg<br /><br /><span class="rem">-- Query 3</span><br /><span class="kwrd">select</span> Id,Username,desg,<span class="kwrd">COUNT</span>(*)<br />[<span class="kwrd">No</span>. <span class="kwrd">of</span> Employees] <span class="kwrd">from</span> @val<br /><span class="kwrd">where</span> desg <span class="kwrd">is</span> <span class="kwrd">null</span> <span class="kwrd">or</span> desg <> <span class="str">'SE'</span><br /><span class="kwrd">group</span> <span class="kwrd">by</span> Id,Username,Desg</pre><br /><br /><p>When we execute the above queries in the Sql Server Management Studio, we would get the following outputs:</p><br /><br /><p><span style="color:#000080;"><strong>Query 1 Result: </strong></span></p><br /><br /><p><a href="http://s838.photobucket.com/albums/zz302/tamilpoo/Codebate/?action=view&current=FullTable.png" target="_blank"><img alt="Full Table Selection" src="http://i838.photobucket.com/albums/zz302/tamilpoo/Codebate/FullTable.png" border="0" /></a></p><br /><br /><p><span style="color:#000000;">This is the output of the entire table we just created.</span></p><br /><br /><p><strong>Query 2 Result:</strong></p><br /><br /><p><a href="http://s838.photobucket.com/albums/zz302/tamilpoo/Codebate/?action=view&current=SelectingCondition.png" target="_blank"><img alt="Condition: desg 'SE'" src="http://i838.photobucket.com/albums/zz302/tamilpoo/Codebate/SelectingCondition.png" border="0" /></a></p><br /><br /><p><span style="color:#000000;">This is the output when I use this condition – <strong>desg <> ‘SE’</strong>. But it should show the remaining rows that are with NULL values.</span></p><br /><br /><p><span style="font-size:+0;"><strong>Query 3 Result:</strong></span> </p><br /><br /><p><a href="http://s838.photobucket.com/albums/zz302/tamilpoo/Codebate/?action=view&current=SelectingNULLs.png" target="_blank"><img alt="Condition: desg IS NULL OR desg 'SE'" src="http://i838.photobucket.com/albums/zz302/tamilpoo/Codebate/SelectingNULLs.png" border="0" /></a></p><br /><br /><p><span style="color:#000000;">when I use this condition – <strong>desg IS NULL or desg <> ‘SE’</strong>, I am able to get the required output. </span></p><br /><br /><p>Somebody who knows can explain the trick ;-)</p><br /><br /><p><span style="color:#000000;"> </span></p>Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com1tag:blogger.com,1999:blog-3096271591668550621.post-4973947647551789682009-07-01T09:28:00.001-07:002009-07-03T10:01:54.844-07:00ASP.NET EMail Validation – Revised.<p>Sometimes back, I had searched to find an easy way to validate email address with some restricted patterns such as fixed domains, common suffices, etc. </p> <p>The very common regular expression for email validation is as we know: </p> <p><strong><span style="color:#000080;">\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*</span></strong></p> <p>But if we want to restrict emails of specific domains, that is also simply possible by : </p> <p><strong><span style="color:#000080;">\w+([-+.']\w+)*@(domA\.com|domB\.com)</span></strong></p> <p>The above expression will validate only if the emails are with <strong><em>@domA.com</em></strong> and <strong><em>@domB.com</em></strong> in the suffix.</p> <p>And When we want to have a specific pattern in the email:</p> <p> <br /><strong><span style="color:#000080;">\w+([-+.']\w+)*@(domA+[A-Za-z0-9]*.com)</span></strong></p> <p>With the above expression, we can validate email ids with the format abc<b>@domA</b>bbb.com, acde<b>@domA</b>cgfdg32.com, etc. As we could have <strong><em>@domA</em></strong> as the part of the email address after <strong>@</strong> symbol.</p>Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com0tag:blogger.com,1999:blog-3096271591668550621.post-83652704095230503492008-12-20T06:45:00.000-08:002009-01-18T06:21:20.536-08:00Inheritance, Polymorphism and Method HidingWhenever I meet .NET people in the code-debate mode, I encounter a common question which is the good example for the concepts like inheritance, polymorphism and method hiding.<br /><br />Check the code snippet below:<br /><strong>Snippet I:</strong><br /><br /><!-- code formatted by http://manoli.net/csharpformat/ --><br /><div class="csharpcode"><br /><span class="kwrd">public</span> <span class="kwrd">class</span> A<br />{<br /><span class="kwrd">public</span> <span class="kwrd">virtual</span> methodA()<br /> {<br /> Console.WriteLine(<span class="str">"From Class A"</span>);<br /> }<br />}<br /><span class="kwrd">public</span> <span class="kwrd">class</span> B : A<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">override</span> methodA()<br /> {<br /> Console.WriteLine(<span class="str">"From Class B"</span>);<br /> }<br />}<br /><span class="kwrd">public</span> <span class="kwrd">class</span> classMain<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args) {<br /> A objA = <span class="kwrd">new</span> A();<br /> B objB = <span class="kwrd">new</span> B();<br /><br><span class="rem">// This calls A's methodA()</span><br /> objA.methodA();<br /><br><br /> <span class="rem">// This calls B's methodA()</span><br /> objB.methodA();<br /><br> objA = <span class="kwrd">new</span> B();<br /><br><br /><span class="rem">// This calls B's methodA()</span><br /> objA.methodA();<br /> }<br />}<br /></div><br /><br />Consider the change in the Classes<em><strong> B </strong></em>and<em><strong> classMain</strong></em>, as follows:<br /><strong>Snippet II:</strong><br /><br /><!-- code formatted by http://manoli.net/csharpformat/ --><br /><div class="csharpcode"><br /><span class="kwrd">public</span> <span class="kwrd">class</span> A<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">virtual</span> methodA()<br /> {<br /> Console.WriteLine(<span class="str">"From Class A"</span>);<br /> }<br />}<br /><br><br /><span class="kwrd">public</span> <span class="kwrd">class</span> B : A<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">new</span> methodA()<br /> {<br /> Console.WriteLine(<span class="str">"From Class B"</span>);<br /> }<br />}<br /><br><br /><span class="kwrd">public</span> <span class="kwrd">class</span> classMain<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)<br /> {<br /> A objA = <span class="kwrd">new</span> A();<br /> B objB = <span class="kwrd">new</span> B();<br /><br><br /> <span class="rem">// This calls A's methodA()</span><br /> <span class="rem">// From the object of class A</span><br /> objA.methodA();<br /><br><br /> <span class="rem">// This calls B's methodA()</span><br /> <span class="rem">// From the object of class B</span><br /> objB.methodA();<br /><br><br /> objA = <span class="kwrd">new</span> B();<br /><br><br /> <span class="rem">// This calls A's methodA()</span><br /> <span class="rem">// From the object of class B</span><br /> ((A)objB).methodA(); <br /> }<br />}<br /></div><br /><br />Hope you got the execution flow and output of the above snippets.<br />I place some questions here:<br /><br />1) In the snippet I, from the <strong>main</strong> class, if I want to call the method <em><strong>methodA()</strong></em> of class <strong>A</strong> by the object of class <strong>B</strong>, I will get compile time error. <em><u>Whats the purpose of inheritance here?</u></em><br /><p>2) In the snippet II, from the <strong>main</strong> class, if I am able to call <strong><em>methodA()</em></strong> of class <strong>A</strong> by the object of class <strong>B</strong>, <em><u>whats the purpose of method overriding then?</u>.</em> (Whenever I see ILDASM, it shows two <em>methodA()</em> in that) .</p><p>3) <em>Whats the significant performance improvement in using method overriding over method hiding?</em><br /></p>Shoot your answers here...Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com2tag:blogger.com,1999:blog-3096271591668550621.post-3209599501437654292008-12-16T08:02:00.000-08:002008-12-16T08:16:44.581-08:00Yet another .NET Blog - CODE4ASP.NET<a href="http://blogger.code4asp.net/" target="_blank">Code For ASP.NET</a> - yet another site for .NET Technologies.<br /><br />Srinath Gnath is the author blogger compiles .NET/C# code digests, who is also a friend and colleague of mine. According to him, this is a kind of knowledge sharing. Like me, he is also a consistent learner for advanced techniques in C# and ASP.NET.<br /><br />For regular Updates, readers can <a href="http://blogger.code4asp.net/" target="_blank">check out his articles here</a>Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com0tag:blogger.com,1999:blog-3096271591668550621.post-64726678672212743922008-12-16T06:47:00.000-08:002008-12-19T23:13:22.085-08:00Welcome CoDebaters !!!<span style="FONT-WEIGHT: bold;font-size:100%;" >" Co<span style="COLOR: rgb(51,102,255)">Debate <span style="COLOR: rgb(102,102,102)">"</span></span></span><br /><br />This term is coined from 2 words ... <span style="COLOR: rgb(102,102,102)">Code & </span><span style="COLOR: rgb(102,102,102)">Debate...</span><br /><br />Debating What ??<br /><br />Of Course...<br /><br />.NET Code..<br /><br />Well, its a great pleasure to write down here for the purpose of debating .NET code.<br /><br />For your note...<br /><br /><span style="FONT-WEIGHT: bold">Technology in CoDebate:</span><br />ASP.NET, C#, Sql Server, VB.NET, AJAX, jQuery,....<br /><br /><span style="FONT-WEIGHT: bold">Possible Topics can be covered</span><span style="FONT-WEIGHT: bold"> in CoDebate</span><span style="FONT-WEIGHT: bold">:</span><br />Advanced Programming Techniques,<br />Discussion on conventional codes,<br />Tips & Tricks,<br />Interview Questions,<br />Book Reviews,<br />General Technology Updates,...<br /><br /><span style="FONT-WEIGHT: bold">Suitable contents for:</span><br />.NET Developers (Advanced/Intermediate/Beginners),<br />Job Seekers(.NET),...<br /><br />Happy Programming...!!!Karthikeyanhttp://www.blogger.com/profile/02626008644253946651noreply@blogger.com2