Separating C # class into header and .cs file

Is there a way to separate the C # class into a header that contains the class definition and then the actual .cs file containing the implementation? I suppose this can be done by creating an interface, but that doesn't seem right. I just need a file where I can just see the class design, and not all the details. This is pretty easy to do in C ++, but I have not seen this with C #.

Thanks in advance.

+3
source share
16 answers

This is the wrong approach. C # is not C ++. Forget about header files .

If you need a class summary, just open Object Explorer in Visual Studio. It will give you a signature of all the methods in your classes.

+23

. , , ...

- MSDN

+15

Visual Studio, , .

Visual Studio , .

dotnet .

+10

( ), #. VS.NET ( ), , , . , ?

+2

, , , ++. . , , , .

+1

interface .

IFoo.cs:

public interface IFoo
{
  int DoFoo();
}

Foo.cs:

public class Foo : IFoo
{
  public int DoFoo()
  {
    return 1;
  }
}
+1

, . (, , ) "". , .

, IDE , Reflector ( ):

http://www.red-gate.com/products/reflector/index.htm

. System.Web.Caching.Cache

public sealed class Cache : IEnumerable
{
    // Fields
    private CacheInternal _cacheInternal;
    public static readonly DateTime NoAbsoluteExpiration;
    public static readonly TimeSpan NoSlidingExpiration;

    // Methods
    static Cache();
    [SecurityPermission(SecurityAction.Demand, Unrestricted=true)]
    public Cache();
    internal Cache(int dummy);
    public object Add(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback);
    public object Get(string key);
    internal object Get(string key, CacheGetOptions getOptions);
    public IDictionaryEnumerator GetEnumerator();
    public void Insert(string key, object value);
    public void Insert(string key, object value, CacheDependency dependencies);
    public void Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration);
    public void Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback);
    public object Remove(string key);
    internal void SetCacheInternal(CacheInternal cacheInternal);
    IEnumerator IEnumerable.GetEnumerator();

    // Properties
    public int Count { get; }
    public long EffectivePercentagePhysicalMemoryLimit { get; }
    public long EffectivePrivateBytesLimit { get; }
    public object this[string key] { get; set; }
}
+1

++, .

, , , , , , , .

/// XML .

+1

IDE?

: .

0

. , .

0

IDE , , ".".

myBadlyNamedObject.

( "ClassName." ), , , , ,

0

, . , , . , , , , .

0

, Refactor → Extract interface.

0

, " IDE ~! ~~", . IDE. , , ? ? , , IDE : ( ) IDE.

, ; , .

0

WinCV - sdk .net 1.0, ++, , .net. google wincv.exe , .net 2.0.

0

0
source

Source: https://habr.com/ru/post/1697299/


All Articles