<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.NET Tips and Tricks &#187; interview</title>
	<atom:link href="http://kossovsky.net/index.php/tag/interview/feed/" rel="self" type="application/rss+xml" />
	<link>http://kossovsky.net</link>
	<description>C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks</description>
	<lastBuildDate>Sat, 25 Dec 2010 08:32:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>C# LINQ Teaser</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:31:00 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teasers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[c-sharp]]></category>
		<category><![CDATA[delegate]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[interview question]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[lt]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[Puzzle]]></category>
		<category><![CDATA[puzzles]]></category>
		<category><![CDATA[string args]]></category>
		<category><![CDATA[tezer]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[toarray]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=517</guid>
		<description><![CDATA[Another great interview question. Will the following code compile and if yes what will be the result of it ? static void Main(string[] args) { int[] array = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Func&#60;int, int&#62; func = i =&#62; { Console.Write(array[i]); return i; }; var result = array.Where(e =&#62; [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.8" /></div><div>Rating: 4.8/<strong>5</strong> (9 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Another great interview question.</p>
<p>Will the following code compile and if yes what will be the result of it ?<br />
<span id="more-517"></span></p>
<pre class="c#" name="code">static void Main(string[] args)
{
    int[] array = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    Func&lt;int, int&gt; func = i =&gt; {
                          Console.Write(array[i]);
                          return i;
                     };

    var result = array.Where(e =&gt; e &lt;= func(2)).ToArray ();
}</pre>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.8" /></div><div>Rating: 4.8/<strong>5</strong> (9 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-linq-teaser%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>C# Byte Iteration Question</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-byte-iteration-question/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-byte-iteration-question/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 08:27:34 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teasers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[byte]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[c-sharp]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[interview question]]></category>
		<category><![CDATA[iteration]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[string args]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=473</guid>
		<description><![CDATA[This one is a great c# interview question &#8211; short and simple, but tricky. static void Main(string[] args) { for (byte b = byte.MinValue; b<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.4" /></div><div>Rating: 4.4/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>This one is a great c# interview question &#8211; short and simple, but tricky.</p>
<p><span id="more-473"></span></p>
<pre class="c-sharp" name="code">
static void Main(string[] args)
{
    for (byte b = byte.MinValue; b <= byte.MaxValue; b++)
        Console.Write(b);
}

// A little tip
// byte.MinValue = 0
// byte.MaxValue = 255
</pre>
<p>How many times the above statement will be executed ?</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.4" /></div><div>Rating: 4.4/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-byte-iteration-question%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-byte-iteration-question/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>C# The &#8220;double&#8221; trouble</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-the-double-trouble/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-the-double-trouble/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 21:37:16 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[Teasers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[c-sharp]]></category>
		<category><![CDATA[d1 d2]]></category>
		<category><![CDATA[digits]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[double trouble]]></category>
		<category><![CDATA[floating]]></category>
		<category><![CDATA[floating point]]></category>
		<category><![CDATA[guarantees]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[numeric value]]></category>
		<category><![CDATA[point]]></category>
		<category><![CDATA[precision]]></category>
		<category><![CDATA[Puzzle]]></category>
		<category><![CDATA[simple answer]]></category>
		<category><![CDATA[string args]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=360</guid>
		<description><![CDATA[This is a very simple question with a not so simple answer&#8230; Forget for a second about .NET. If someone asks you how much is 1.000025 &#8211; 0.000025 your answer will probably be &#8220;1&#8243; and correct. An easy question, right ? Now, let&#8217;s go back to .NET and check if our calculations are correct. static [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.3" /></div><div>Rating: 4.3/<strong>5</strong> (6 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>This is a very simple question with a not so simple answer&#8230;</p>
<p>Forget for a second about .NET.<br />
If someone asks you how much is 1.000025 &#8211; 0.000025 your answer will probably be &#8220;1&#8243; and correct. An easy question, right ?</p>
<p>Now, let&#8217;s go back to .NET and check if our calculations are correct.</p>
<p><span id="more-360"></span></p>
<pre class="c-sharp" name="code">        static void Main(string[] args)
        {
            double d1 = 1.000025;
            double d2 = 0.000025;
            Console.WriteLine((d1 - d2) == 1);
        }</pre>
<p>If you think the result will be &#8220;true&#8221;&#8230; well, it&#8217;s not.</p>
<p>Let&#8217;s see another example :</p>
<pre class="c-sharp" name="code">        static void Main(string[] args)
        {
            double d1 = 1.000025;
            double d2 = 0.000025;

            // Will result 1
            Console.WriteLine(d1 - d2);

            // Will result 0.99999999999999989
            Console.WriteLine((d1 - d2).ToString ("R"));
        }</pre>
<p>For those who might not know, the meaning of ToString(&#8220;R&#8221;) is <a title="MSDN - Standard Numeric Format Strings" href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" target="_blank">Round-trip</a>.</p>
<blockquote><p>This format is supported only for the Single and Double types. The round-trip specifier guarantees that a numeric value converted to a string will be parsed back into the same numeric value. When a numeric value is formatted using this specifier, it is first tested using the general format, with 15 spaces of precision for a Double and 7 spaces of precision for a Single. If the value is successfully parsed back to the same numeric value, it is formatted using the general format specifier. However, if the value is not successfully parsed back to the same numeric value, then the value is formatted using 17 digits of precision for a Double and 9 digits of precision for a Single.</p></blockquote>
<p>So, what happened here ? Is it a bug ?<br />
The answer is &#8211; NO, IT&#8217;S NOT A BUG ( and it&#8217;s not happening only on my computer ).</p>
<p>The thing is, that the above is about how .NET rounding a floating point number.<br />
I won&#8217;t explain here the math ( there is already a great <a title="What Every Computer Scientist Should Know About Floating-Point Arithmetic" href="http://docs.sun.com/source/806-3568/ncg_goldberg.html" target="_blank">article</a> explaining it ), and i won&#8217;t say don&#8217;t use floating point types.</p>
<p>You just need to know that when you are using it &#8211; be carefull, especialy in equations and formatting, otherwise your calculations will be wrong and your result not accurate.</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.3" /></div><div>Rating: 4.3/<strong>5</strong> (6 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-the-double-trouble%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-the-double-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Increment operator (++) question</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-increment-operator-question/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-increment-operator-question/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 22:30:32 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teasers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[increment]]></category>
		<category><![CDATA[increment operator]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[operators]]></category>
		<category><![CDATA[puzzles]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=293</guid>
		<description><![CDATA[Well, this is a nice one. We all familiar with incremental operators, but from what i saw yesterday&#8230; well, there is no need to give a developer some tricky assignment so he could find a way to make some bugs. 3bj4h786fc What will be the output of the next code ? static void Main(string[] args) [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (6 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Well, this is a nice one. We all familiar with incremental operators, but from what i saw yesterday&#8230; well, there is no need to give a developer some tricky assignment so he could find a way to make some bugs.</p>
<div style="display:none">3bj4h786fc</div>
<p><span id="more-293"></span><br />
What will be the output of the next code ?</p>
<pre class="c-sharp" name="code">
static void Main(string[] args)
{
    int i = 100;
    for (int n = 0; n < 100; n++)
    {
         i = i++;
    }
    Console.WriteLine(i);
}
</pre>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (6 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-increment-operator-question%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-increment-operator-question/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>C# Inheritance Question</title>
		<link>http://kossovsky.net/index.php/2009/06/csharp-inheritance-question/</link>
		<comments>http://kossovsky.net/index.php/2009/06/csharp-inheritance-question/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 21:39:33 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Inheritance]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[Overloading]]></category>
		<category><![CDATA[public static string]]></category>
		<category><![CDATA[puzzles]]></category>
		<category><![CDATA[simple questions]]></category>
		<category><![CDATA[string result]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=191</guid>
		<description><![CDATA[The following are two simple questions related to C# inheritance. Please try to give an answer without executing the code, otherwise where is the fun part ? // Question #1 class Program { static void Main(string[] args) { int i = 13; string Result = B.Get(i); Console.WriteLine(Result); } } public class A { public static [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.6" /></div><div>Rating: 4.6/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>The following are two simple questions related to C# inheritance.<br />
Please try to give an answer without executing the code, otherwise where is the fun part ?<br />
<span id="more-191"></span></p>
<pre class="c-sharp" name="code">
    // Question #1
    class Program
    {
        static void Main(string[] args)
        {
            int i = 13;
            string Result = B.Get(i);
            Console.WriteLine(Result);
        }
    }

    public class A
    {
        public static string Get(int Value) {
            return "A";
        }
    }

    public class B : A
    {
        public static string Get(float Value)
        {
            return "B";
        }
    }
</pre>
<pre class="c-sharp" name="code">
    // Question #2
    class Program
    {
        static void Main(string[] args)
        {
            int i = 13;
            string Result = B.Get(i);
            Console.WriteLine(Result);
        }
    }

    public class B
    {
        public static string Get(float Value)
        {
            return "B";
        }

        public static string Get(int Value) {
            return "A";
        }
    }
</pre>
<p>What will be the result of the above code parts ?</p>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.6" /></div><div>Rating: 4.6/<strong>5</strong> (5 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F06%2Fcsharp-inheritance-question%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/06/csharp-inheritance-question/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

