TypeCode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DragonLord
    New Member
    • Mar 2007
    • 122

    #1

    TypeCode

    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!!
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Have you set your editor setting in the control panel (of tsdn) as enhanced mode?

    Need a moderator / admin to change your code...cant follow it. Once thats done decypering it will be easier :D unless u plan to manually remove all the size and color tags

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I would have a go at fixing it, but I have no idea what all the <summary> tags mean.

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        Originally posted by Killer42
        I would have a go at fixing it, but I have no idea what all the <summary> tags mean.
        Arent those xml comments?
        except the '' will have to be removed and replaced by ///

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Shashi Sadasivan
          Arent those xml comments?
          except the '' will have to be removed and replaced by ///
          Since I have no idea what you mean, I'd better not touch it.

          Comment

          • DragonLord
            New Member
            • Mar 2007
            • 122

            #6
            it should look fine now i did it in notepad and removed all the tags

            Comment

            • DragonLord
              New Member
              • Mar 2007
              • 122

              #7
              oh those tags, forget those they are in the comments. i am just focusing on the lines that use TypeCode as a datatype it is a vb .net data type and i have no idea how to replace it in C#

              Comment

              • DragonLord
                New Member
                • Mar 2007
                • 122

                #8
                C#:

                public TypeCode DataType

                VB .NET:

                Public Property DataType() As TypeCode

                The VB.Net one is fine it works but I want to use C# so i used a converter and it gave me the above... however TypeCode is not recognized by the C# compiler so what do i replace it with????

                Comment

                • Shashi Sadasivan
                  Recognized Expert Top Contributor
                  • Aug 2007
                  • 1435

                  #9
                  typecode is not a datatype, its an enumerator

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    Is TypeCode used to pass in a a DateType? Like in the days of c++ myclass<T> kinda deal?
                    Just try using Type

                    Comment

                    • DragonLord
                      New Member
                      • Mar 2007
                      • 122

                      #11
                      Originally posted by Plater
                      Is TypeCode used to pass in a a DateType? Like in the days of c++ myclass<T> kinda deal?
                      Just try using Type

                      See told you I was a newbie and yes i believe it is used to pass in a datatype.

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        Well I'm not sure hot to fix this:
                        Code:
                        public class TextFieldEnumerator : TypeCode, System.Collections.IEnumerator

                        But this would be like:
                        Code:
                        public System.Type DataType
                        {
                           get
                           {
                              return _dataType;
                           }
                           set
                           {
                              _dataType = value;
                           }
                        }

                        Comment

                        • DragonLord
                          New Member
                          • Mar 2007
                          • 122

                          #13
                          OK how could we write this:

                          Comment

                          • DragonLord
                            New Member
                            • Mar 2007
                            • 122

                            #14
                            OK how could we write this:

                            VB .NET
                            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

                            in C#??

                            Comment

                            • Plater
                              Recognized Expert Expert
                              • Apr 2007
                              • 7872

                              #15
                              this didn't work?

                              Code:
                              public class TextFieldEnumerator : object, System.Collections.IEnumerator 
                              { 
                                  private System.Collections.IEnumerator iEnBase; 
                                  private System.Collections.IEnumerable iEnLocal; 
                              }

                              Comment

                              Working...