读书人

怎么将下面的C#代码转换成VB.NET代码

发布时间: 2012-01-26 19:40:46 作者: rapoo

如何将下面的C#代码转换成VB.NET代码?急
namespace Morell.GroupPanel
{
public delegate void PropChangeHandler(TabPage tabPage, Property prop, object oldValue);
public enum Property
{
Text,
ImageIndex
}
}

namespace Morell.GroupPanel
{
public class GroupPanel : System.Windows.Forms.UserControl
{
private void StartEdit(object sender, EventArgs e)
{
this.Capture = true;
}
}
}

namespace Morell.GroupPanel
{
[ToolboxItem(false)]public class TabPage : Panel
{
public event PropChangeHandler PropertyChanged;
public event EventHandler StartEdit;

public void OnPropertyChanged(Property prop, object oldValue)
{
// Is the event registered
if (PropertyChanged != null)
// Raise the event
PropertyChanged(this, prop, oldValue);
}

Public Sub BeginEdit()
If Not (StartEdit Is Nothing) Then
StartEdit(Me, New EventArgs())
End If
End Sub
}
}

[解决办法]
If Not (StartEdit Is Nothing) Then
StartEdit(Me, New EventArgs())
End If

if(StartEdit != null)
{
StartEdit(this, New EventArgs());
}
[解决办法]
If Not object.Equals (StartEdit ,Nothing) Then
StartEdit(Me, New EventArgs())
End If

您看看msdn
Remarks
The Is operator determines if two object references refer to the same object. However, it does not perform value comparisons. If object1 and object2 both refer to the exact same object instance, result is True; if they do not, result is False.
就是说is只是比较引用对象
不是sqlsever那种比较是否是null


Object.Equals (Object, Object) Determines whether the specified Object instances are considered equal.
Supported by the .NET Compact Framework.
这个才是比较!
[解决办法]
Namespace Morell.GroupPanel
Public delegate void PropChangeHandler(TabPage tabPage, Property prop, Object oldValue)
Public Enum Property
Text
ImageIndex
End Enum
End Namespace

Namespace Morell.GroupPanel
Public Class GroupPanel
Inherits System.Windows.Forms.UserControl
Private Sub StartEdit(ByVal sender As Object, ByVal e As EventArgs)
Me.Capture = True
End Sub
End Class
End Namespace

Namespace Morell.GroupPanel
(ToolboxItem(False))Public Class TabPage
Inherits Panel
Public event PropChangeHandler PropertyChanged
Public event EventHandler StartEdit

Public Sub OnPropertyChanged(ByVal prop As Property, ByVal oldValue As Object)
' Is the event registered
If Not PropertyChanged Is Nothing Then
' Raise the event


PropertyChanged(this, prop, oldValue)
End If
End Sub

Public Sub BeginEdit()
If Not (StartEdit Is Nothing) Then
StartEdit(Me, New EventArgs())
End If
End Sub
End Class
End Namespace

'----------------------------
' 蒋玉龙向您问好
' 转换代码来源于网络,非本人原创,谢谢!
'----------------------------
以上代码自动转换——如果有问题,概不负责,呵呵~~
==================================================================
博客空间:http://blog.csdn.net/lovingkiss
资源下载:http://download.csdn.net/user/lovingkiss
Email:loving-kiss@163.com
本人说明: <我的帖子我做主,结贴率保持100%>
优惠接单开发,信誉保证,Q64180940(请清楚注明业务还是技术咨询)
==================================================================

读书人网 >C#

热点推荐