<?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"><channel><title><![CDATA[CS508 GDB 1 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
]]></description><link>https://community.secnto.com//topic/2188/cs508-gdb-1-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 21:14:19 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/2188.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Feb 2021 16:40:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:45:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<p dir="auto">Anonymous Method Limitations</p>
<p dir="auto">It cannot contain jump statement like goto, break or continue.<br />
It cannot access ref or out parameter of an outer method.<br />
It cannot have or access unsafe code.<br />
It cannot be used on the left side of the is operator.</p>
]]></description><link>https://community.secnto.com//post/6482</link><guid isPermaLink="true">https://community.secnto.com//post/6482</guid><dc:creator><![CDATA[Pak Love]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:45:49 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:45:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<pre><code>Anonymous methods can be used as event handlers:

Example: Anonymous Method as Event Handler
saveButton.Click += delegate(Object o, EventArgs e)
{ 
    System.Windows.Forms.MessageBox.Show("Save Successfully!"); 
};
</code></pre>
]]></description><link>https://community.secnto.com//post/6481</link><guid isPermaLink="true">https://community.secnto.com//post/6481</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:44:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zaasmi" aria-label="Profile: zaasmi">@<bdi>zaasmi</bdi></a> said in <a href="/post/6479">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<p dir="auto">Anonymous methods can also be passed to a method that accepts the delegate as a parameter.</p>
<p dir="auto">In the following example, PrintHelperMethod() takes the first parameters of the Print delegate:</p>
<pre><code>Example: Anonymous Method as Parameter
public delegate void Print(int value);

class Program
{
    public static void PrintHelperMethod(Print printDel,int val)
    { 
        val += 10;
        printDel(val);
    }

    static void Main(string[] args)
    {
        PrintHelperMethod(delegate(int val) { Console.WriteLine("Anonymous method: {0}", val); }, 100);
    }
}

</code></pre>
</blockquote>
<p dir="auto">Output:<br />
Anonymous method: 110</p>
]]></description><link>https://community.secnto.com//post/6480</link><guid isPermaLink="true">https://community.secnto.com//post/6480</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:44:42 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:44:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<p dir="auto">Anonymous methods can also be passed to a method that accepts the delegate as a parameter.</p>
<p dir="auto">In the following example, PrintHelperMethod() takes the first parameters of the Print delegate:</p>
<pre><code>Example: Anonymous Method as Parameter
public delegate void Print(int value);

class Program
{
    public static void PrintHelperMethod(Print printDel,int val)
    { 
        val += 10;
        printDel(val);
    }

    static void Main(string[] args)
    {
        PrintHelperMethod(delegate(int val) { Console.WriteLine("Anonymous method: {0}", val); }, 100);
    }
}

</code></pre>
]]></description><link>https://community.secnto.com//post/6479</link><guid isPermaLink="true">https://community.secnto.com//post/6479</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:44:33 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:43:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zaasmi" aria-label="Profile: zaasmi">@<bdi>zaasmi</bdi></a> said in <a href="/post/6477">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<p dir="auto">Anonymous methods can access variables defined in an outer function.</p>
<pre><code>Example: Anonymous Method
public delegate void Print(int value);

static void Main(string[] args)
{
    int i = 10;
    
    Print prnt = delegate(int val) {
        val += i;
        Console.WriteLine("Anonymous method: {0}", val); 
    };

    prnt(100);
}
</code></pre>
</blockquote>
<p dir="auto">Anonymous method: 110</p>
]]></description><link>https://community.secnto.com//post/6478</link><guid isPermaLink="true">https://community.secnto.com//post/6478</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:43:49 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:43:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Re: <a href="/topic/242/cs508-gdb-1-solution-and-discussion">CS508 GDB.1 Solution and Discussion</a></p>
<p dir="auto">Total Marks	5<br />
Starting Date	Monday, February 15, 2021<br />
Closing Date	Tuesday, February 16, 2021<br />
Status	Open<br />
Question Title	GDB<br />
Question Description	<br />
In a programming world, Lambda Expression (i.e. lambda function) is essentially a block of code that can be assigned to a variable, passed as an argument, or returned from a function call. It has been part of several programming languages like Smalltalk, Lisp, Ruby, Scala, Python, Java and C# etc. for quite some time.</p>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
<p dir="auto">Listing 1: (anonymous method in C# to check if a student is teenager or not)</p>
<p dir="auto">delegate(Student std) {</p>
<p dir="auto">return std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">}</p>
<p dir="auto">While the same functionality can be achieved by using lambda as;</p>
<p dir="auto">Listing 2: (checking if a student is teenager or not using lambda in C#)</p>
<p dir="auto">std =&gt; std.Age &gt; 12 &amp;&amp; std.Age &lt; 20;</p>
<p dir="auto">Here, we can see that the code has been shortened (i.e. writability increased). However, it makes the code relatively difficult to understand as “std” in listing 2 is ambiguous (i.e. readability decreased). But what about Reliability?</p>
<p dir="auto">Being a programming language expert, you are required to compare both approaches (i.e. code written with/without lambda) and state which one is better in terms of Reliability in C# programming language.</p>
</blockquote>
<p dir="auto">Anonymous methods can access variables defined in an outer function.</p>
<pre><code>Example: Anonymous Method
public delegate void Print(int value);

static void Main(string[] args)
{
    int i = 10;
    
    Print prnt = delegate(int val) {
        val += i;
        Console.WriteLine("Anonymous method: {0}", val); 
    };

    prnt(100);
}
</code></pre>
]]></description><link>https://community.secnto.com//post/6477</link><guid isPermaLink="true">https://community.secnto.com//post/6477</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:43:36 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:43:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zaasmi" aria-label="Profile: zaasmi">@<bdi>zaasmi</bdi></a> said in <a href="/post/6475">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
</blockquote>
<p dir="auto">Example: Anonymous Method</p>
<pre><code>public delegate void Print(int value);

static void Main(string[] args)
{
    Print print = delegate(int val) { 
        Console.WriteLine("Inside Anonymous method. Value: {0}", val); 
    };

    print(100);
}
Try it

</code></pre>
</blockquote>
<p dir="auto">Inside Anonymous method. Value: 100</p>
]]></description><link>https://community.secnto.com//post/6476</link><guid isPermaLink="true">https://community.secnto.com//post/6476</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to CS508 GDB 1 Solution and Discussion on Tue, 16 Feb 2021 16:42:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ozair" aria-label="Profile: ozair">@<bdi>ozair</bdi></a> said in <a href="/post/6474">CS508 GDB 1 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">In context of C# programming, a lambda can be used instead of an anonymous method/function where we do not need to provide access modifier, return type and even name of the method. For example, the following anonymous method checks if a student is teenager or not:</p>
</blockquote>
<p dir="auto">Example: Anonymous Method</p>
<pre><code>public delegate void Print(int value);

static void Main(string[] args)
{
    Print print = delegate(int val) { 
        Console.WriteLine("Inside Anonymous method. Value: {0}", val); 
    };

    print(100);
}
Try it

</code></pre>
]]></description><link>https://community.secnto.com//post/6475</link><guid isPermaLink="true">https://community.secnto.com//post/6475</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 16 Feb 2021 16:42:47 GMT</pubDate></item></channel></rss>