using 中写 return 一样会释放using 中对象 但是会在外面定义一个一样的对象 赋值后 释放 最后 return 外面定义的那个对象
static DataTable getDataTable()
{
"))
{
SqlCommand com = new SqlCommand("", con);
SqlDataAdapter sda = new SqlDataAdapter(com);
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
Reflector 反编译后
private static DataTable getDataTable()
{
DataTable table2;
"))
{
SqlCommand selectCommand = new SqlCommand("", connection);
SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
using (DataTable table = new DataTable())
{
adapter.Fill(table);
table2 = table;
}
}
return table2;
}
private static DataTable getDataTable()
{
DataTable table2;
"))
{
SqlCommand selectCommand = new SqlCommand("", connection);
SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
using (DataTable table = new DataTable())
{
adapter.Fill(table);
table2 = table;
}
}
return table2;
}

using 中写 return 一样会释放using 中对象 但是会在外面定义一个一样的对象 赋值后 释放 最后 return 外面定义的那个对象
using 中写 return 一样会释放using 中对象 但是会在外面定义一个一样的对象 赋值后 释放 最后 return 外面定义的那个对象的更多相关文章
- jquery中定义数组并给数组赋值后转为json格式为[]问题的解决
一.问题描述:jquery定义一个空数组,并赋值,结果转为json格式后打印值为空 我原本是这样写的,但是show_data值一直为[] var export_data = [];export_dat ...
- oracle调用java方法的例子(下面所有代码都是在sql/plus中写)
在Oracle中调用Java程序,注意:java方法必须是static类型的,如果想在JAVA中使用system.out/err输出log. 需要在oracle 中执行"call dbms_ ...
- Linux启动kettle及linux和windows中kettle往hdfs中写数据(3)
在xmanager中的xshell运行进入图形化界面 sh spoon.sh 新建一个job
- DirectShow中写push模式的source filter流程 + 源代码(内附详细注释)
虽然网上已有很多关于DirectShow写source filter的资料,不过很多刚开始学的朋友总说讲的不是很清楚(可能其中作者省略了许多他认为简 单的过程),读者总希望看到象第一步怎么做,第二步怎 ...
- DirectShow中写push模式的source filter流程 + 源码(内附具体凝视)
尽管网上已有非常多关于DirectShow写source filter的资料.只是非常多刚開始学的朋友总说讲的不是非常清楚(可能当中作者省略了很多他觉得简 单的过程).读者总希望看到象第一步怎么做,第 ...
- 在mybatis中写sql语句的一些体会
本文会使用一个案例,就mybatis的一些基础语法进行讲解.案例中使用到的数据库表和对象如下: article表:这个表存放的是文章的基础信息 -- ------------------------- ...
- 【Filter 不登陆无法访问】web项目中写一个过滤器实现用户不登陆,直接给链接,无法进入页面的功能
在web项目中写一个过滤器实现用户不登陆,直接给链接,无法进入页面,而重定向到登陆界面的功能. 项目是用springMVC+spring+hibernate实现 (和这个没有多大关系) 第一步: 首先 ...
- python中写shell(转)
python中写shell,亲测可用,转自stackoverflow To run a bash script, copy from stackoverflow def run_script(scri ...
- Android 手写Binder 教你理解android中的进程间通信
关于Binder,我就不解释的太多了,网上一搜资料一堆,但是估计还是很多人理解的有困难.今天就教你如何从 app层面来理解好Binder. 其实就从我们普通app开发者的角度来看,仅仅对于androi ...
随机推荐
- Tkinter 鼠标键盘事件(一)
一: 鼠标事件 <Button-1> 鼠标左键单击 ...
- JavaEE 项目部署方式
一.手动部署 二.自动部署 “自动化”的具体体现:向版本库提交新的代码后,应用服务器上自动部署,用户或测试人员使用的马上就是最新的应用程序. 搭建上述持续集成环境可以把整个构建.部署过程自动化,很大程 ...
- luoguP3172 [CQOI2015]选数
题意 所求即为: \(\sum\limits_{i_1=L}^{R}\sum\limits_{i_2=L}^{R}...\sum\limits_{i_k=L}^{R}[\gcd(i_1,i_2,... ...
- 2.第一个Vue程序
1.IDEA中安装Vue.js插件 2.建立项目以及html文件 1.创建一个 HTML 文件 2.引入 Vue.js <script src="https://cdn.jsdeliv ...
- <Math> 50 367
50. Pow(x, n) abs (Integer.MIN_VALUE) > Integer.MAX_VALUE class Solution { public double myPow(do ...
- [LeetCode] 879. Profitable Schemes 盈利方案
There are G people in a gang, and a list of various crimes they could commit. The i-th crime generat ...
- [LeetCode] 694. Number of Distinct Islands 不同岛屿的个数
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- [LeetCode] 172. Factorial Trailing Zeroes 求阶乘末尾零的个数
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...
- for...in 、for...of 、forEach 的区别
无论是for…in还是for…of语句都是迭代一些东西.它们之间的主要区别在于它们的迭代方式. 1.for…in 语句以原始插入顺序迭代对象的可枚举属性.2.for…of 语句遍历可迭代对象定义要迭代 ...
- mac下mysql安装、卸载、基本操作
2018-06-08 10:57:26 张广森 阅读数 6584更多 分类专栏: mac mysql 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本 ...