我有界面:
Public Interface ICSIItem
Sub Initialize()
Event AnswerValueChanged(ByVal sender As Object, ByVal e As NotebookAnswerChangedEventArgs)
Property DataContext() As Object
End Interface
和转换器http://www.developerfusion.com/tools/convert/vb-to-csharp/
public interface ICSIItem
{
void Initialize();
event AnswerValueChangedEventHandler AnswerValueChanged;
delegate void AnswerValueChangedEventHandler(object sender, NotebookAnswerChangedEventArgs e);
object DataContext { get; set; }
}
并且resharper告诉我,委托不能在界面中。
这是NotebookAnswerChangedEventArgs类
public class NotebookAnswerChangedEventArgs : System.EventArgs
{
public string NewAnswer;
public string PreviousAnswer;
public NotebookAnswerChangedEventArgs(string newAnswer, string previousAnswer) : base()
{
this.NewAnswer = newAnswer;
this.PreviousAnswer = previousAnswer;
}
}
你能帮忙进行这种转换,并请更好的转换器网站,因为这是非常差的:/
答案 0 :(得分:2)
public delegate void AnswerValueChangedEventHandler(
object sender,
NotebookAnswerChangedEventArgs e);
public interface ICSIItem {
void Initialize();
event AnswerValueChangedEventHandler AnswerValueChanged;
object DataContext { get; set; }
}
答案 1 :(得分:1)
public interface ICSIItem {
void Initialize();
event EventHandler<NotebookAnswerChangedEventArgs> AnswerValueChanged;
object DataContext { get; set; }
}
请注意 - 您的eventargs支持使用EventHandler - 我认为在这种情况下您应该使用EventHandler而不是重新定义自己的委托。
但我不知道有什么好的转换器。你为什么要转换?只需将您的VB.net代码放入dll并从C#中使用它 - 如果您编写新代码,请在C#中执行,并在需要时随时间转换。