简体   繁体   中英

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#. 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. I am trying to define these as class wide variables, but C# does not seem to like this. 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

public ClassName(...)

Check this article on MSDN:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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