SqlDataReader类没有任何构造函数? [英] SqlDataReader Class does not have any Constructor ?

查看:136
本文介绍了SqlDataReader类没有任何构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问)我在某些视频中听说SqlDataReader类没有任何构造函数。这是真的吗?

据我所知,没有类可以有零构造函数。如果我不写,

在类中声明任何构造函数,那么C#编译器会将默认构造函数添加到类中。



Q)如果我的话代码就像

SqlDataReader dr;

有人说dr是对象。

是对象还是引用变量?

Q) I heard in some video that 'SqlDataReader' class does not have any constructor. Is it true ?
As far as my knowledge there is no class can have zero constructors. If I don not write
declare any constructor in a class then C# compiler will add default constructor to the class.

Q)If my Code is like
SqlDataReader dr;
Some people are saying that dr is object.
Is it a Object or Reference Variable ?

推荐答案

您可以查看MSDN文档 - http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader%28v=vs.110%29.aspx [<一个href =http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader%28v=vs.110%29.aspxtarget =_ blanktitle =New Window> ^ ]。

根据这个 - 要创建一个SqlDataReader,你必须调用SqlCommand对象的ExecuteReader方法,而不是直接使用构造函数。



dr 是一个包含指向对象的指针的变量。

A ref 与众不同 - http: //msdn.microsoft.com/en-us/library/14akc2c7.aspx [ ^ ]。
You can check MSDN documentation - http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader%28v=vs.110%29.aspx[^].
According to this - "To create a SqlDataReader, you must call the ExecuteReader method of the SqlCommand object, instead of directly using a constructor."

dr is a variable that holds a pointer to an object.
A ref is different - http://msdn.microsoft.com/en-us/library/14akc2c7.aspx[^].


1。构造函数未公开,不公开:

1. The constructor is not exposed, that is not publicly available:
要创建SqlDataReader,必须调用ExecuteReader方法SqlCommand对象,而不是直接使用构造函数。
To create a SqlDataReader, you must call the ExecuteReader method of the SqlCommand object, instead of directly using a constructor.





2. dr 是一个引用变量。在



2. dr is a reference variable. After the

SqlDatareader dr



语句之后, dr 是等于 null


这篇关于SqlDataReader类没有任何构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆