473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Converting c# to vb.net

Hi

I've run some binary tree c# code on various on-line converters. The code
compiles fine in c# but raises a few issues in vb.net. This is all pretty
new to me, so if this is obvious pls excuse me, but I wonder if someone
could explain why vb complains, and possible work rounds.

Thanks

Simon

a) vb complains of the following

Public Sub New(ByVal data As T)
Me.New(data, Nothing, Nothing)
End Sub

"Error 1 Overload resolution failed because no accessible 'New' is most
specific for these arguments:
'Public Sub New(data As T, left As BinaryTree(Of T), right As
BinaryTree(Of T))': Not most specific.
'Public Sub New(data As T, left As T, right As T)': Not most specific."

Public Sub New(ByVal data As T, ByVal left As T, ByVal right As T)
Me.New(data, New BinaryTree(Of T)(left), New BinaryTree(Of
T)(right))
End Sub

Public Sub New(ByVal data As T, ByVal left As BinaryTree(Of T), ByVal right
As BinaryTree(Of T))
m_leftSubtree = lef
m_rightSubtree = right
Me.m_data = data
End Sub

b)
Public Interface ITree(Of T)

Sub Add(ByVal child As ITree(Of T))
Function GetChild(ByVal index As Integer) As ITree(Of T)
....

End Interface

Public Class BinaryTree(Of T)
Implements ITree(Of T)

Private m_leftSubtree As BinaryTree(Of T)
Private m_rightSubtree As BinaryTree(Of T)
Private m_data As T

.....

Public Function GetChild(ByVal index As Integer) As BinaryTree(Of T)
If index = 0 Then
Return m_leftSubtree
ElseIf index = 1 Then
Return m_rightSubtree
Else
Throw New ArgumentOutOfRangeException()
End If
End Function

Function GetChild(ByVal index As Integer) As ITree(Of T) Implements
ITree(Of T).GetChild
Return Me.GetChild(index)
End Function

Error 7 'Public Function GetChild(index As Integer) As ITree(Of T)' and
'Public Function GetChild(index As Integer) As BinaryTree(Of T)' cannot
overload each other because they differ only by return types.

c)
Public Class BinaryTree(Of T)
Implements System.Collections.IEnumerable

Function GetEnumerator() As System.Collections.IEnumerator Implements
System.Collections.IEnumerable.GetEnumerator
Return Me.GetEnumerator()
End Function

Public Function Contains(ByVal item As T) As Boolean
Using enumerator As IEnumerator(Of T) = Me.GetEnumerator()
...
Error 8 Option Strict On disallows implicit conversions from
'System.Collections.IEnumerator' to
'System.Collections.Generic.IEnumerator(Of T)'.
Jun 22 '07 #1
1 1977
Post the original C# code. Most of the on-line converter don't handle
generics accurately, so the conversion is incorrect.
--
David Anton
www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Python
Instant C#
Instant VB
Instant C++
Instant Python
C++ to C# Converter
C++ to VB Converter
"Simon Woods" wrote:
Hi

I've run some binary tree c# code on various on-line converters. The code
compiles fine in c# but raises a few issues in vb.net. This is all pretty
new to me, so if this is obvious pls excuse me, but I wonder if someone
could explain why vb complains, and possible work rounds.

Thanks

Simon

a) vb complains of the following

Public Sub New(ByVal data As T)
Me.New(data, Nothing, Nothing)
End Sub

"Error 1 Overload resolution failed because no accessible 'New' is most
specific for these arguments:
'Public Sub New(data As T, left As BinaryTree(Of T), right As
BinaryTree(Of T))': Not most specific.
'Public Sub New(data As T, left As T, right As T)': Not most specific."

Public Sub New(ByVal data As T, ByVal left As T, ByVal right As T)
Me.New(data, New BinaryTree(Of T)(left), New BinaryTree(Of
T)(right))
End Sub

Public Sub New(ByVal data As T, ByVal left As BinaryTree(Of T), ByVal right
As BinaryTree(Of T))
m_leftSubtree = lef
m_rightSubtree = right
Me.m_data = data
End Sub

b)
Public Interface ITree(Of T)

Sub Add(ByVal child As ITree(Of T))
Function GetChild(ByVal index As Integer) As ITree(Of T)
....

End Interface

Public Class BinaryTree(Of T)
Implements ITree(Of T)

Private m_leftSubtree As BinaryTree(Of T)
Private m_rightSubtree As BinaryTree(Of T)
Private m_data As T

.....

Public Function GetChild(ByVal index As Integer) As BinaryTree(Of T)
If index = 0 Then
Return m_leftSubtree
ElseIf index = 1 Then
Return m_rightSubtree
Else
Throw New ArgumentOutOfRangeException()
End If
End Function

Function GetChild(ByVal index As Integer) As ITree(Of T) Implements
ITree(Of T).GetChild
Return Me.GetChild(index)
End Function

Error 7 'Public Function GetChild(index As Integer) As ITree(Of T)' and
'Public Function GetChild(index As Integer) As BinaryTree(Of T)' cannot
overload each other because they differ only by return types.

c)
Public Class BinaryTree(Of T)
Implements System.Collections.IEnumerable

Function GetEnumerator() As System.Collections.IEnumerator Implements
System.Collections.IEnumerable.GetEnumerator
Return Me.GetEnumerator()
End Function

Public Function Contains(ByVal item As T) As Boolean
Using enumerator As IEnumerator(Of T) = Me.GetEnumerator()
...
Error 8 Option Strict On disallows implicit conversions from
'System.Collections.IEnumerator' to
'System.Collections.Generic.IEnumerator(Of T)'.
Jun 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.