简体   繁体   English

多次定义此成员

[英]This member is defined more than once

I have looked at all the other member defined more than once threads and could not find one that was like mine. 我查看了所有不止一次定义线程的其他成员,并且找不到像我这样的成员。 If there is one and I missed it I am sorry. 如果有一个我错过了,对不起。 Most of what we do here is VB.NET, but I am trying to convert some existing code to C#. 我们在这里所做的大部分工作是VB.NET,但我正在尝试将一些现有代码转换为C#。 The problem I am having is I am getting a "This member is defined more than once" Here is my code. 我遇到的问题是我收到“多次定义此成员”的代码。

private System.Data.SqlClient.SqlConnection mSqlConn;
private bool mLoadOnly = false;

public void New(bool isLoadOnly) {

        mLoadOnly = isLoadOnly;

        mSqlConn = new System.Data.SqlClient.SqlConnection(GetConnStr());

    }

So I get the error in the constructor. 所以我得到构造函数中的错误。 I do not see how I am defining mLoadOnly or mSqlConn again. 我看不到如何再次定义mLoadOnly或mSqlConn。 I am trying to define these as class wide variables, but C# does not seem to like this. 我试图将它们定义为类范围的变量,但是C#似乎不喜欢这样。 How should I go about doing this? 我应该怎么做呢? Thank you! 谢谢!

It looks like you have the constructor defined multiple times in your code file. 看起来您在代码文件中多次定义了构造函数。 Also, constructors in C# are declared differently, ie 另外,C#中的构造函数的声明方式也不同,即

public ClassName(...)

Check this article on MSDN: 在MSDN上查看此文章:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM