有一些我正在使用的VB代碼。我從原來的VB代碼重寫一些事情,在C#c#在屬性上實現接口
我的VB類的內部:
Implements actionBaseClass
Private m_config_url As String
Private m_config_unc As String
Private m_connection_string As String
Private m_xml_doc_path_or_data As String
Private m_fpid As String
Private m_cancelled As Boolean
Private m_xml_doc_element As Xml.XmlElement
Private m_removing As Boolean
Private m_xml_doc As New Xml.XmlDocument
Property XMLDocPathOrData() As String Implements actionBaseClass.XMLDocPathOrData
Get
XMLDocPathOrData = m_xml_doc_path_or_data
End Get
Set(ByVal Value As String)
m_xml_doc_path_or_data = Value
End Set
End Property
WriteOnly Property FPId() As String Implements actionBaseClass.FPId
Set(ByVal Value As String)
m_fpid = Value
End Set
End Property
我已轉化的C#接口:
interface actionBaseClass
{
public bool UseStringData { get; }
string XMLDocPathOrData { get; set; }
string FPId { set; }
string ConfigURL { set; }
string ConfigUNC { set; }
string ConnectionString { set; }
bool Cancelled { get; }
void ActionMe();
void DisposeMe();
}
我已轉化的C#類到目前爲止:
public partial class Form1 : Form, actionBaseClass
{
#region Public Implements from base class
private string m_config_url, m_config_unc, m_connection_string, m_xml_doc_path_or_data, m_fpid;
private bool m_cancelled, m_removing;
private XmlElement m_xml_doc_element;
private new XmlDocument m_xml_doc;
public bool UseStringData
{
get { return false; }
}
public string XMLDocPathOrData
{
get { return actionInterface.XMLDocPathOrData = m_xml_doc_path_or_data; }
set { m_xml_doc_path_or_data = value; }
}
public string FPId
{
set { m_fpid = value; }
}
如何在C#中使用上述VB代碼中的屬性聲明中的Implements?或者你沒有在C#中使用Implements <interface_name>
檢查[這篇文章](http://www.codeproject.com/Articles/1000374/Explicit-Interface-VS-Implicit-Interface-in-Csharp) –
據我所知,你已經這樣做隱式,這裏'公共部分類Form1:Form,actionBaseClass'。 – rotgers