Question

I have a base class that is written in VB.net. This base class has a property. I have a C# class that is drived from that vb class. I need to set property here so I can give a value on to it. This is my property in vb.net class:

  Public MustInherit Class FTPDownloaderBase

   Public WriteOnly Property FilesToDownload() As ArrayList
    Set(ByVal Value As ArrayList)
        _filesToDownload = Value
    End Set
  End Property

this is my C# class:

 public class FTPDownloaderClass:FTPDownloader.FTPDownloaderBase
{



  public Array FilesToDownloadC
  {
      get
      {
          return base.FilesToDownload;
      }


  }

}

But I get this error on the line: return base.FilesToDownload; The property or indexer 'FTPDownloded.FtpDownloderbase.FilesToDownload' cannot be used in this context beacuse it lacks the get accessor.

How I can get access to this property and give a value to it in my C# code?

Solution: I have add a Get to the VB base class and it is accessible now like this:

  Public Property FilesToDownload() As ArrayList
    Get
        Return _filesToDownload
    End Get
    Set(ByVal Value As ArrayList)
        _filesToDownload = Value
    End Set
End Property
Was it helpful?

Solution

You can not access the property if it doesn't have a get accessor, unless you use reflection.

The easiest solution would be to add the Get accessor to the VB Class, or to make _filesToDownload protected instead of private.

If you can not change the base class:

return typeof(FTPDownloader.FTPDownloaderBase).GetFields(BindingFlags.NonPublic).Single(f => f.Name == "_filesToDownload").GetValue(this);

OTHER TIPS

You would have to modify the base class and either add a get accessor, or add a method to return the property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top