Why can't I inherit IO.Directory?

Why can't I create a class in VB.NET that inherits System.IO.Directory ? According to Lutz Roeder, it is not declared as NotInheritable !

I want to create a utility class that will add Directory class functionality. For example, I want to add the Directory.Move function.

Please inform and I will send you six packages. OK, I don’t think I’m sending anything, but if you came to the bar tonight, I would pick you up and then beat you in a pool.

+2
inheritance
Sep 25 '08 at 20:17
source share
4 answers

From .NET metadata.

 namespace System.IO { // Summary: // Exposes static methods for creating, moving, and enumerating through directories // and subdirectories. This class cannot be inherited. [ComVisible(true)] public static class Directory 

You cannot inherit from a static class.

+11
Sep 25 '08 at 20:19
source share

Do you use C # 3.0 VB.NET 2008 - then you can add the Extension Method

+5
Sep 25 '08 at 20:18
source share

If you use the DirectoryInfo class, you will have access to the MoveTo function.

EDIT: I will fix myself ... The static class class already has a Move method.

+1
Sep 25 '08 at 20:19
source share

I would suggest that Reflector is not typing the sealed attribute for VB correctly (or maybe just not displaying it correctly). If you look at IL, it is sealed:

class public abstract auto ansi sealed directory beforefieldinit

0
Sep 25 '08 at 22:29
source share



All Articles