ASP
例如
using System
ASP
場景
當在某個代碼段中使用了類的實例
要達到這樣的目的
例如
public static DataTable GetTable(string sql
{
DataTable dtRet = new DataTable();
using (SqlConnection sc = new SqlConnection(connStringName))
{
using (SqlDataAdapter sqa = new SqlDataAdapter(sql
{
sqa
sqa
return dtRet;
}
}
}
ASP
這種做法有個好處就是當同一個cs引用了兩個不同的命名空間
例如
using System;
using System
using System
using System
using aClass = ConsoleApplication
using bClass = ConsoleApplication
namespace ConsoleApplication
{
public class MyClass
{
public override string ToString()
{
return
}
}
class TestUsing
{
}
}
namespace ConsoleApplication
{
class MyClass
{
public override string ToString()
{
return
}
}
}
namespace TestUsing
{
using ConsoleApplication
using ConsoleApplication
class ClassTestUsing
{
static void Main()
{
aClass my
Console
bClass my
Console
Console
Console
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/12433.html