Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an interface method which when not implemented shows exception code in VB.Net, just like in C#

Tags:

c#

vb.net

I have seen in C# that Interfaces when implemented in a class, give methods with an NotImplementedException block in them.

This way

public interface IDisposable
{
    void Dispose();
}

and when implimenting it

public class Class1 : IDisposable
{
    public void Dispose()
    {
        throw new NotImplementedException();
    }
}

Now my question

  1. Is this only a C# built-in facility and is not available in VB.Net?
  2. If No, how can I have this functionality in VB.Net?
like image 320
Nikhil Agrawal Avatar asked Jan 29 '26 15:01

Nikhil Agrawal


1 Answers

You can use a Visual Studio plug-in like JustCode, which offers such a feature for VB.Net:

Interface Foo
    Sub Bar()
End Interface

Class FooBar
    Implements Foo

    Public Sub Bar() Implements Foo.Bar     -+
        ' TODO: Implement this method        +-- these lines are autogenerated
        Throw New NotImplementedException()  |
    End Sub                                 -+

End Class
like image 157
sloth Avatar answered Feb 01 '26 05:02

sloth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!