Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:01:19+00:00 2026-06-14T05:01:19+00:00

I have a class that implements IDataReader and the needed functions are written, but

  • 0

I have a class that implements IDataReader and the needed functions are written, but I get an error message stating

Class ‘CSVDataReader’ must implement ‘Function GetBoolean(i As Integer) As Boolean’ for interface ‘System.Data.IDataRecord’.

IDataReader has many functions and properties. How do I implement the functions without rewriting them all?

Here is my class

    Public Class CSVDataReader
    Implements IDataReader
    Private stream As StreamReader
    Private columnsByName As New Dictionary(Of String, Integer)()
    Private columnsByOrdinal As New Dictionary(Of Integer, String)()
    Private currentRow As String()
    Private _isClosed As Boolean = True

    Public Sub New(fileName As String)
        If Not File.Exists(fileName) Then
            Throw New Exception("File [" & fileName & "] does not exist.")
        End If

        Me.stream = New StreamReader(fileName)

        Dim headers As String() = stream.ReadLine().Split(",")
        For i As Integer = 0 To headers.Length - 1
            columnsByName.Add(headers(i), i)
            columnsByOrdinal.Add(i, headers(i))
        Next

        _isClosed = False
    End Sub

    Public Sub Close()
        If stream IsNot Nothing Then
            stream.Close()
        End If
        _isClosed = True
    End Sub

    Public ReadOnly Property FieldCount() As Integer
        Get
            Return columnsByName.Count
        End Get
    End Property

    ''' <summary>
    ''' This is the main function that does the work - it reads in the next line of data and parses the values into ordinals.
    ''' </summary>
    ''' <returns>A value indicating whether the EOF was reached or not.</returns>
    Public Function Read() As Boolean
        If stream Is Nothing Then
            Return False
        End If
        If stream.EndOfStream Then
            Return False
        End If

        currentRow = stream.ReadLine().Split(",")
        Return True
    End Function

    Public Function GetValue(i As Integer) As Object
        Return currentRow(i)
    End Function

    Public Function GetName(i As Integer) As String
        Return columnsByOrdinal(i)
    End Function

    Public Function GetOrdinal(name As String) As Integer
        Return columnsByName(name)
    End Function

    Public Function GetOrdinal(name As String) As Integer
        Return columnsByName(name)
    End Function
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:01:21+00:00Added an answer on June 14, 2026 at 5:01 am

    You have to implement all the methods and properties.

    An interface is a contract – if an object says it can provide the services listed on the interface, it has to provide all of them. An interface is not a base class – there is no “template” code to fall back on if you don’t implement something.

    It’s OK not to put any code in the methods/properties you aren’t interested in (I usually put Throw New NotImplementedException so I know when I’ve inadvertently called a method I wasn’t planning to). But the stubs have to be there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a class that implements IEnumerable and IEnumerator but does not implement
I have a class that implements the Enumeration<T> interface, but Java's foreach loop requires
I have a class that implements IEnumerable , but doesn't implement IEnumerable<T> . I
Let's say I have a class that implements ArrayAccess but doesn't allow the addition
I have a class that implements the IDisposable interface. I am using a webclient
I have a class that implements properties in a specific way, to handle some
I have a class that implements IComparable. public class MyClass : IComparable<MyClass> { public
I have a class that implements InvocationHandler as below: public class MyProxyClass implements InvocationHandler
When I have a class that implements INotifyPropertyChanged, is it ok to expose the
Context: I have a class that implements a Session, maintaining a TCP connection to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.