<?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>家有小虎 &#187; C#</title>
	<atom:link href="http://jiahu.net/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://jiahu.net</link>
	<description>我在路上, 你不在身旁. 想你的时候, 温暖依然.</description>
	<lastBuildDate>Sun, 15 Jan 2012 03:12:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>.Net中var的使用方式</title>
		<link>http://jiahu.net/dotnet%e4%b8%advar%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e5%bc%8f.htm</link>
		<comments>http://jiahu.net/dotnet%e4%b8%advar%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e5%bc%8f.htm#comments</comments>
		<pubDate>Thu, 30 Jun 2011 15:28:07 +0000</pubDate>
		<dc:creator>@ouc</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://jiahu.net/?p=1661</guid>
		<description><![CDATA[The following restrictions apply to implicitly-typed variable declarations: var can only be used when a local variable is declared and initialized in the same statement; the variable cannot be initialized to null, or to a method group or an anonymous &#8230; <a href="http://jiahu.net/dotnet%e4%b8%advar%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e5%bc%8f.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following restrictions apply to implicitly-typed variable declarations:</p>
<ul>
<li>var can only be used when a local variable is declared and initialized in the same statement; the variable cannot be initialized to null, or to a method group or an anonymous function.</li>
<li>var cannot be used on fields at class scope.</li>
<li>Variables declared by using var cannot be used in the initialization expression. In other words, this expression is legal: int i = (i = 20); but this expression produces a compile-time error: var i = (i = 20);</li>
<li>Multiple implicitly-typed variables cannot be initialized in the same statement.</li>
<li>If a type named var is in scope, then the var keyword will resolve to that type name and will not be treated as part of an implicitly typed local variable declaration.</li>
</ul>
<p>You may find that var can also be useful with query expressions in which the exact constructed type of the query variable is difficult to determine. This can occur with grouping and ordering operations.</p>
<p>The var keyword can also be useful when the specific type of the variable is tedious to type on the keyboard, or is obvious, or does not add to the readability of the code. One example where var is helpful in this manner is with nested generic types such as those used with group operations. In the following query, the type of the query variable is IEnumerable&gt;. As long as you and others who must maintain your code understand this, there is no problem with using implicit typing for convenience and brevity.</p>
<p>However, the use of var does  have at least the potential to make your code more difficult to  understand for other developers. For that reason, <span style="color: #ff0000;">the C# documentation  generally uses var only when it is required</span>.</p>
<p>Link: <a href="http://msdn.microsoft.com/en-us/library/bb384061.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb384061.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jiahu.net/dotnet%e4%b8%advar%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e5%bc%8f.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transaction for OracleConnection in .Net</title>
		<link>http://jiahu.net/transactionscope-for-oracle-in-net.htm</link>
		<comments>http://jiahu.net/transactionscope-for-oracle-in-net.htm#comments</comments>
		<pubDate>Thu, 03 Jun 2010 22:58:13 +0000</pubDate>
		<dc:creator>@ouc</dc:creator>
				<category><![CDATA[工作]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jiahu.net/?p=1480</guid>
		<description><![CDATA[1. 单个数据库连接 可以直接使用OracleTransaction对象做事务处理 using(var transaction = connection.BeginTransaction()) { .....在这个作用域上的数据库操作，必须基于这个transaction using(var command = new OracleCommand(commandText, connection) { Transaction = transaction }) { ... } ... transaction.Commit(); //transaction.Rollback(); } 2. 多个数据库连接 可以使用TransactionScope对象来维护多个数据库连接中的事务处理 var options = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, Timeout &#8230; <a href="http://jiahu.net/transactionscope-for-oracle-in-net.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1. 单个数据库连接</p>
<p>可以直接使用OracleTransaction对象做事务处理</p>
<pre lang="csharp">
using(var transaction = connection.BeginTransaction())
{
.....在这个作用域上的数据库操作，必须基于这个transaction
using(var command = new OracleCommand(commandText, connection) { Transaction = transaction })
{
...
}
...
transaction.Commit(); //transaction.Rollback();
}
</pre>
<p>2. 多个数据库连接</p>
<p>可以使用TransactionScope对象来维护多个数据库连接中的事务处理</p>
<pre lang="csharp">
var options = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, Timeout = new TimeSpan(0, 2, 0) };

using (var transaction = new TransactionScope(TransactionScopeOption.Required, options))
{
.....在这个作用域里面的数据库操作，不需要传递transaction对象
using(var connection1 = new OracleConnection(connectionString1))
{
...
}

using(var connection2 = new OracleConnection(connectionString2))
{
...
}

transaction.Complete();
}
</pre>
<p>注1: 使用TransactionScope对象前，需要添加引用System.Transaction</p>
<p>注2: 对于多个Oracle连接来说，使用TransactionScope对象前，需要安装Oracle Services For MTS (Microsoft Transaction Server)。下载地址：<a href="http://goo.gl/XrKn" target="_blank">http://goo.gl/XrKn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jiahu.net/transactionscope-for-oracle-in-net.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert integer to Enum instance</title>
		<link>http://jiahu.net/convert-integer-to-enum-instance.htm</link>
		<comments>http://jiahu.net/convert-integer-to-enum-instance.htm#comments</comments>
		<pubDate>Mon, 27 Oct 2008 04:19:03 +0000</pubDate>
		<dc:creator>@ouc</dc:creator>
				<category><![CDATA[工作]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://cngator.net/?p=774</guid>
		<description><![CDATA[public void EnumInstanceFromInt() { // The .NET Framework contains an Enum called DayOfWeek. // Let&#8217;s generate some Enum instances from int values. // Usually you wouldn&#8217;t cast an instance of an existing Enum to an int // in order to &#8230; <a href="http://jiahu.net/convert-integer-to-enum-instance.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>public void EnumInstanceFromInt()<br />
{<br />
// The .NET Framework contains an Enum called DayOfWeek.<br />
// Let&#8217;s generate some Enum instances from int values.</p>
<p>// Usually you wouldn&#8217;t cast an instance of an existing Enum to an int<br />
// in order to create an Enum instance.  :-)  You would have the actual<br />
// integer value, perhaps a value from a database where the int value of<br />
// the enum was stored.</p>
<p>DayOfWeek wednesday =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Wednesday);<br />
DayOfWeek sunday =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Sunday);<br />
DayOfWeek tgif =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Friday);</p>
<p>lblOutput.Text = wednesday.ToString()<br />
+ “.  Int value = ” + ((int)wednesday).ToString() + “\n”;<br />
lblOutput.Text += sunday.ToString()<br />
+ “.  Int value = ” + ((int)sunday).ToString() + “\n”;<br />
lblOutput.Text += tgif.ToString()<br />
+ “.  Int value = ” + ((int)tgif).ToString() + “\n”;<br />
}</p>
<p>Result:</p>
<p>Wednesday. Int value = 3<br />
Sunday. Int value = 0<br />
Friday. Int value = 5</p>
<p>Link: <a href="http://www.cambiaresearch.com/c4/52a7e5fe-c7fc-49ab-b21d-37e6194687f3/Convert-Integer-To-Enum-Instance-in-csharp.aspx" target="_blank">http://www.cambiaresearch.com/c4/52a7e5fe-c7fc-49ab-b21d-37e6194687f3/Convert-Integer-To-Enum-Instance-in-csharp.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jiahu.net/convert-integer-to-enum-instance.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

