<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>C# Frequently Asked Questions : C# Language 2.0</title><link>http://blogs.msdn.com/csharpfaq/archive/tags/C_2300_+Language+2.0/default.aspx</link><description>Tags: C# Language 2.0</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Is it possible to output the command-line used to build a project in Visual Studio?</title><link>http://blogs.msdn.com/csharpfaq/archive/2004/11/30/272587.aspx</link><pubDate>Wed, 01 Dec 2004 01:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:272587</guid><dc:creator>CSharpFAQ</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/csharpfaq/comments/272587.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csharpfaq/commentrss.aspx?PostID=272587</wfw:commentRss><description>&lt;P&gt;Now that Whidbey has been out in Beta for more than a few months, it seems worth revisiting some frequently asked questions which have different (better?) answers now. &lt;/P&gt;
&lt;P&gt;In Everett (v7.1) the answer used to be No. &lt;/P&gt;
&lt;P&gt;However, in Whidbey (v8.0), the answer is Yes (and No). &lt;/P&gt;
&lt;P&gt;For the yes part of the answer, after building, go to the Output Window, select "Show Output from: Build", and about half way down you will see a section like this: &lt;/P&gt;&lt;code&gt;
&lt;P&gt;Target "Compile" in project "ConsoleApplication1.csproj" &lt;/P&gt;
&lt;P&gt;Task "Csc" &lt;/P&gt;
&lt;P&gt;Csc.exe /noconfig /warn:4 /define:DEBUG;TRACE /debug+ /optimize- /out:obj\Debug\ConsoleApplication1.exe /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.31125\System.Data.dll, C:\WINDOWS.0\Microsoft.NET\Framework\v2.0.31125\System.XML.dll, C:\WINDOWS\Microsoft.NET\Framework\v2.0.31125\System.dll /target:exe /win32icon:App.ico AssemblyInfo.cs Class1.cs &lt;/P&gt;
&lt;P&gt;The task is invoking the IDE's in-process compiler to perform the equivalent of the above command-line. &lt;/P&gt;&lt;/code&gt;
&lt;P&gt;Now for the no part of the answer. The project system does not actually execute this command line as part of the build process. As the output says, the IDE directly calls its own in-process compiler to perform the equivalent. However, in all cases, you should get the same results using the command line suggested in the output window. If you don't, you could be looking at a bug. &lt;/P&gt;
&lt;P&gt;Note: before you cut and paste the build output to the command line, remember to add the path to CSC.EXE &lt;/P&gt;
&lt;P&gt;[Author: SantoshZ] &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=272587" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/IDE/default.aspx">IDE</category><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/General/default.aspx">General</category><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/C_2300_+Language+2.0/default.aspx">C# Language 2.0</category></item><item><title>Why does C#'s iterators feature spit out a class definition instead of a struct definition?</title><link>http://blogs.msdn.com/csharpfaq/archive/2004/07/20/188865.aspx</link><pubDate>Tue, 20 Jul 2004 17:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:188865</guid><dc:creator>CSharpFAQ</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/csharpfaq/comments/188865.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csharpfaq/commentrss.aspx?PostID=188865</wfw:commentRss><description>&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;STRONG&gt;Q:&lt;/STRONG&gt; Why does C#'s iterators feature spit out a class definition instead of a struct definition?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;The iterators feature in C# generates classes that implement the enumerators required. This is detailed in the &lt;A href="http://msdn.microsoft.com/vcsharp/language"&gt;C# Specification&lt;/A&gt;. Why doesn't it use structs, which would be more efficient.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;STRONG&gt;A:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;There are two reasons.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;(1) Naming. We generate classes that implement the enumerator interfaces and then&amp;nbsp;use only&amp;nbsp;the interface types in the public protocol. That way the names of the generated classes&amp;nbsp;are purely an implementation detail. This is highly desirable from a versioning perspective. With a struct-based implementation, to get any of the efficiencies associated with structs we would have to use their types in the public protocol (using interfaces the structs would just get boxed). That in turns means we'd have to invent a name mangling scheme for the structs. In particular, iterators returning IEnumerable&amp;lt;T&amp;gt; would be complicated because a type could have multiple such members that differ only in their parameter list, meaning that the parameter list would have to be part of the mangled name.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;(2) Structs don't work in recursive cases. For example, a TreeNode type could implement an iterator that recursively iterates first the left and then the right subtrees by foreach-ing contained members that are also of type TreeNode.&amp;nbsp;With a struct-based&amp;nbsp;implementation this would translate into an enumerator&amp;nbsp;struct that contains a field of its own type--which isn't possible. (Think of it this way: A foreach statement obtains an enumerator and stores that in a local variable. In iterators, local variables are transformed into fields in the enumerator. A recursive iterator would therefore create a struct with a member of its own type.) You could argue that we can detect whether or not iterators are recursive and adjust our code generation scheme accordingly.&amp;nbsp;However,&amp;nbsp;you then end up with a versioning problem when a previously non-recursive iterator changes its (supposedly private) implementation to become recursive.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class=160142815-20072004&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;Anders (via &lt;A href="http://blogs.msdn.com/ericgu"&gt;Eric&lt;/A&gt;)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=188865" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/C_2300_+Language+and+Compiler/default.aspx">C# Language and Compiler</category><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/C_2300_+Language+2.0/default.aspx">C# Language 2.0</category></item><item><title>Why don't nullable relational operators return bool? instead of bool?</title><link>http://blogs.msdn.com/csharpfaq/archive/2004/05/25/141570.aspx</link><pubDate>Tue, 25 May 2004 18:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:141570</guid><dc:creator>CSharpFAQ</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/csharpfaq/comments/141570.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csharpfaq/commentrss.aspx?PostID=141570</wfw:commentRss><description>&lt;P&gt;Q: Why don't nullable relational operators return &amp;#8220;bool?&amp;#8221; instead of &amp;#8220;bool&amp;#8220;?&lt;/P&gt;
&lt;P&gt;Nullable types are a new feature of &lt;A href="http://msdn.microsoft.com/vcsharp/team/language/default.aspx"&gt;C# 2.0&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;When dealing with nullable types, if you write the following:&lt;/P&gt;
&lt;P&gt;int? i = 15;&lt;BR&gt;int? j = 16;&lt;/P&gt;
&lt;P&gt;the type of &lt;/P&gt;
&lt;P&gt;i == j&lt;/P&gt;
&lt;P&gt;is a normal bool, rather than a bool? (ie nullable bool). Why?&lt;/P&gt;
&lt;P&gt;A: In our initial designs, we spent a fair amount of time discussing what the behavior should be here, and how we should cross over from the three-valued nullable world to the two-valued &amp;#8220;normal C#&amp;#8220; world. &lt;/P&gt;
&lt;P&gt;Consider the following method:&lt;/P&gt;
&lt;P&gt;void Process(int? p)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (p == null)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do some processing...&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;This seems like a very natural thing for a C# user to want to write. But if equality is three-valued, comparing anything to null always returns a null value (ie null isn't equal to anything), and therefore such a comparison can never succeed. Instead, the user would have to write:&lt;/P&gt;
&lt;P&gt;if (!p.HasValue)&lt;/P&gt;
&lt;P&gt;or something similar. We decided that the value of having a model that was consistent with the way users were used to dealing with reference null was pretty high, and therefore decided to make the relational operators return bool.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=141570" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csharpfaq/archive/tags/C_2300_+Language+2.0/default.aspx">C# Language 2.0</category></item></channel></rss>