Reputation: 5129
I'm wondering how this can be converted to VB.NET.
private void RaiseStreamVolumeNotification()
{
if (StreamVolume != null)
{
StreamVolume(this, new StreamVolumeEventArgs() { MaxSampleValues = (float[])maxSamples.Clone() });
}
}
public class StreamVolumeEventArgs : EventArgs
{
public float[] MaxSampleValues { get; set; }
}
I'm trying to convert it using an online converter, but either it fails, or it converts it incorrectly. One converter, which I think is the best one, converts it to this:
Public Class StreamVolumeEventArgs
Inherits EventArgs
Private _MaxSampleValues As Single()
Public Property MaxSampleValues() As Single()
Get
Return _MaxSampleValues
End Get
Set(ByVal value As Single())
_MaxSampleValues = value
End Set
End Property
End Class
Upvotes: 0
Views: 389
Reputation:
SharpDevelop (aka #Develop) has an excellent code converter. It can be used for converting single files or whole projects.
Upvotes: 0
Reputation: 2045
Have you tried converting them separately? You have a function which appears to be outside of any class, followed by a class, all in the same codespace.
Your function should convert to
Private Sub RaiseStreamVolumeNotification()
RaiseEvent StreamVolume(Me, New StreamVolumeEventArgs(){ .MaxSampleValues = maxSamples.Clone() })
End Sub
Your class should convert to
Public Class StreamVolumeEventArgs
Inherits EventArgs
Private _MaxSampleValues As Single()
Public Property MaxSampleValues() As Single()
Get
Return _MaxSampleValues
End Get
Set(ByVal value As Single())
_MaxSampleValues = value
End Set
End Property
End Class
Upvotes: 0
Reputation: 35117
There might be some slight issues.
Private Sub RaiseStreamVolumeNotification()
Dim SVEA As New StreamVolumeEventArgs()
SVEA.MaxSampleValues = CType(maxSamples.Clone(), Single())
If Not StreamVolume Is Nothing Then
StreamVolume(this, SVEA)
End If
End Sub
Public Class StreamVolumeEventArgs Inheirits EventArgs
Private _MaxSampleValues As Single()
Public Property MaxSampleValues As Single()
Get
Return _MaxSampleValues
End Get
Set(value as Single())
_MaxSampleValues = value
End Set
End Property
End Class
Upvotes: 1
Reputation: 754715
Try this (assuming VS2008 / VB9)
Public Sub RaiseStreamVolumeNotification()
Raise StreamVolume(Me, New StreamVolume() { .MaxSampleValues = maxSamples.Clone() })
End Sub
Public Class StreamVolumeEventArgs
Inherits EventArgs
Private _maxSampleValues As Float()
Public Property MaxSampleValues As Float()
Get
Return _maxSampleValues
End Get
Set (value As Float())
_maxSampleValues = value
End Set
End Property
End Class
Upvotes: 0