Partial Interface in C#

The simplest way is just to try it :)

But yes, partial interfaces are allowed.

Valid locations for the partial modifier (with C# 3.0 spec references):

  • Classes (10.1.2)
  • Structs (11.1.2)
  • Interfaces (13.1.2)
  • Methods (C# 3.0+) (10.2.7; 10.6.8)

Section 10.2 of the spec contains most of the general details for partial types.

Invalid locations:

  • Enums
  • Delegates

Yes, it does.

Partial Classes and Methods (C# Programming Guide) at MSDN

Restrictions:

  • All partial-type interface definitions meant to be parts of the same type must be modified with partial
  • The partial modifier can only appear immediately before the keyword interface.
  • All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file).

Partial intefaces are primary used when code generation is involved. For example when one part of an interface is generated and the other one is user-written.


It does, but an important question would be why?

Partial classes are there so that you can extend auto-generated code. VS can generate a form file, or code behind, or Linq to SQL accessor and you can extend it using a partial.

I'd avoid using partials just to split up classes (or in this case interfaces) as generally that generates more confusion than it's worth.

In this case I'd investigate why this needs to be across multiple files - factory pattern interfaces can make tracking back through you code more complex, but here you'd be tracking back through multiple files.


Yes, it does.