Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Java, a <code>static</code> inner class has no implicit access to the members of its enclosing type. In C#, <em>all</em> nested types have no such access to their parent type's members; there is no modifier you need to add in C# to trigger this behavior.</p> <p>In C#, <code>static</code> classes are <code>abstract sealed</code>, so they cannot be created nor derived -- this is not the same meaning as in Java. Additionally, interfaces cannot contain type declarations of their own.</p> <p>Try something like this:</p> <pre><code>public interface IActivation { double Func(double inputput); } public class S1 : IActivation { public static readonly S1 Instance = new S1(); private S1() { } public double Func(double input) { if (input &gt; 0) return 1.0; return 0.0; } } </code></pre> <hr> <p>If your goal is to provide default implementations in some "readable" way (though I dispute that <code>IActivator.S1()</code> is inherently more readable...) then you could create a static factory class:</p> <pre><code>public static class Activator { public static S1 S1 { get { return S1.Instance; // Or you could do this if you make the S1 constructor public: // return new S1(); } } } </code></pre> <p>However, I dispute the claim that this is more readable or helpful. Visual Studio will, when constructing an object in the context of a particular type, display all of that type's subtypes. So if you do this (<code>|</code> represents the cursor):</p> <pre><code>IActivator foo = new | </code></pre> <p>You should get a neat list of all of the classes in your current scope that implement IActivotor.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload