Ok here is the situation i am porting a project from vb.net to C# and i have the following issues and i don't know how to resolve them.
VB.NET
[code=vbnet]
Public Class TextFieldEnumer ator
Inherits Object
Implements System.Collecti ons.IEnumerator
Private iEnBase As System.Collecti ons.IEnumerator
Private iEnLocal As System.Collecti ons.IEnumerable
''' <summary>
''' Enumerator constructor
''' </summary>
Public Sub New(ByVal texMappings As TextFieldCollec tion)
MyBase.New()
Me.iEnLocal = CType(texMappin gs, System.Collecti ons.IEnumerable )
Me.iEnBase = iEnLocal.GetEnu merator
End Sub
''' <summary>
''' Gets the current element from the collection (strongly typed)
''' </summary>
Public ReadOnly Property Current() As TextField
Get
Return CType(iEnBase.C urrent, TextField)
End Get
End Property
''' <summary>
''' Gets the current element from the collection
''' </summary>
ReadOnly Property System_Collecti ons_IEnumerator _Current() As Object Implements System.Collecti ons.IEnumerator .Current
Get
Return iEnBase.Current
End Get
End Property
''' <summary>
''' Advances the enumerator to the next element of the collection
''' </summary>
Public Function MoveNext() As Boolean
Return iEnBase.MoveNex t
End Function
''' <summary>
''' Advances the enumerator to the next element of the collection
''' </summary>
Function System_Collecti ons_IEnumerator _MoveNext() As Boolean Implements System.Collecti ons.IEnumerator .MoveNext
Return iEnBase.MoveNex t
End Function
''' <summary>
''' Sets the enumerator to the first element in the collection
''' </summary>
Public Sub Reset()
iEnBase.Reset()
End Sub
''' <summary>
''' Sets the enumerator to the first element in the collection
''' </summary>
Sub System_Collecti ons_IEnumerator _Reset() Implements System.Collecti ons.IEnumerator .Reset
iEnBase.Reset()
End Sub
End Class
[/code]
C# converted code :
[code=cpp]
public class TextFieldEnumer ator : TypeCode, System.Collecti ons.IEnumerator
{
private System.Collecti ons.IEnumerator iEnBase;
private System.Collecti ons.IEnumerable iEnLocal;
// '' <summary>
// '' Enumerator constructor
// '' </summary>
public TextFieldEnumer ator(TextFieldC ollection texMappings)
{
this.iEnLocal = ((System.Collec tions.IEnumerab le)(texMappings ));
this.iEnBase = iEnLocal.GetEnu merator;
}
// '' <summary>
// '' Gets the current element from the collection (strongly typed)
// '' </summary>
public TextField Current
{
get
{
return ((TextField)(iE nBase.Current)) ;
}
}
object System_Collecti ons_IEnumerator _Current
{
get
{
return iEnBase.Current ;
}
}
public bool MoveNext()
{
return iEnBase.MoveNex t;
}
// '' <summary>
// '' Advances the enumerator to the next element of the collection
// '' </summary>
bool System_Collecti ons_IEnumerator _MoveNext()
{
return iEnBase.MoveNex t;
}
// '' <summary>
// '' Sets the enumerator to the first element in the collection
// '' </summary>
public void Reset()
{
iEnBase.Reset() ;
}
// '' <summary>
// '' Sets the enumerator to the first element in the collection
// '' </summary>
void System_Collecti ons_IEnumerator _Reset()
{
iEnBase.Reset() ;
}
}
[/CODE]
AND number 2.....
.NET
[code=vbnet]
Public Property DataType() As TypeCode
Get
Return _dataType
End Get
Set(ByVal Value As TypeCode)
_dataType = Value
End Set
End Property
C#
public TypeCode DataType
{
get
{
return _dataType;
}
set
{
_dataType = value;
}
}
[/CODE]
The C# doesn't work because it doesn't recognize TypeCode for both converstions, what can i replace the Typecode with in C# to get this working ? Any help someone can offer would be appreciated for this newbie!!
VB.NET
[code=vbnet]
Public Class TextFieldEnumer ator
Inherits Object
Implements System.Collecti ons.IEnumerator
Private iEnBase As System.Collecti ons.IEnumerator
Private iEnLocal As System.Collecti ons.IEnumerable
''' <summary>
''' Enumerator constructor
''' </summary>
Public Sub New(ByVal texMappings As TextFieldCollec tion)
MyBase.New()
Me.iEnLocal = CType(texMappin gs, System.Collecti ons.IEnumerable )
Me.iEnBase = iEnLocal.GetEnu merator
End Sub
''' <summary>
''' Gets the current element from the collection (strongly typed)
''' </summary>
Public ReadOnly Property Current() As TextField
Get
Return CType(iEnBase.C urrent, TextField)
End Get
End Property
''' <summary>
''' Gets the current element from the collection
''' </summary>
ReadOnly Property System_Collecti ons_IEnumerator _Current() As Object Implements System.Collecti ons.IEnumerator .Current
Get
Return iEnBase.Current
End Get
End Property
''' <summary>
''' Advances the enumerator to the next element of the collection
''' </summary>
Public Function MoveNext() As Boolean
Return iEnBase.MoveNex t
End Function
''' <summary>
''' Advances the enumerator to the next element of the collection
''' </summary>
Function System_Collecti ons_IEnumerator _MoveNext() As Boolean Implements System.Collecti ons.IEnumerator .MoveNext
Return iEnBase.MoveNex t
End Function
''' <summary>
''' Sets the enumerator to the first element in the collection
''' </summary>
Public Sub Reset()
iEnBase.Reset()
End Sub
''' <summary>
''' Sets the enumerator to the first element in the collection
''' </summary>
Sub System_Collecti ons_IEnumerator _Reset() Implements System.Collecti ons.IEnumerator .Reset
iEnBase.Reset()
End Sub
End Class
[/code]
C# converted code :
[code=cpp]
public class TextFieldEnumer ator : TypeCode, System.Collecti ons.IEnumerator
{
private System.Collecti ons.IEnumerator iEnBase;
private System.Collecti ons.IEnumerable iEnLocal;
// '' <summary>
// '' Enumerator constructor
// '' </summary>
public TextFieldEnumer ator(TextFieldC ollection texMappings)
{
this.iEnLocal = ((System.Collec tions.IEnumerab le)(texMappings ));
this.iEnBase = iEnLocal.GetEnu merator;
}
// '' <summary>
// '' Gets the current element from the collection (strongly typed)
// '' </summary>
public TextField Current
{
get
{
return ((TextField)(iE nBase.Current)) ;
}
}
object System_Collecti ons_IEnumerator _Current
{
get
{
return iEnBase.Current ;
}
}
public bool MoveNext()
{
return iEnBase.MoveNex t;
}
// '' <summary>
// '' Advances the enumerator to the next element of the collection
// '' </summary>
bool System_Collecti ons_IEnumerator _MoveNext()
{
return iEnBase.MoveNex t;
}
// '' <summary>
// '' Sets the enumerator to the first element in the collection
// '' </summary>
public void Reset()
{
iEnBase.Reset() ;
}
// '' <summary>
// '' Sets the enumerator to the first element in the collection
// '' </summary>
void System_Collecti ons_IEnumerator _Reset()
{
iEnBase.Reset() ;
}
}
[/CODE]
AND number 2.....
.NET
[code=vbnet]
Public Property DataType() As TypeCode
Get
Return _dataType
End Get
Set(ByVal Value As TypeCode)
_dataType = Value
End Set
End Property
C#
public TypeCode DataType
{
get
{
return _dataType;
}
set
{
_dataType = value;
}
}
[/CODE]
The C# doesn't work because it doesn't recognize TypeCode for both converstions, what can i replace the Typecode with in C# to get this working ? Any help someone can offer would be appreciated for this newbie!!
Comment