On Wed, 29 Oct 2014 07:54:39 -0000, Paulo Pinto <pj...@progtools.org> wrote:

On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
Hello,everyone,
I've written some projects in C#,find the 'partial' keyword is very userful,which lets the auto codes in another single file,my codes are very easy to update.
But  what the same thing in D?

Thank you,every one.

Maybe mixins might be a possibility.

Something like..

class Foo
{
  mixin(import("auto-generated.d"));
}

where auto-generated.d has class members/methods but no "class Foo" itself.


Partial classes are used in C# wherever you need to combine auto-generated code and user code into a single class. So, the Windows GUI builder does it placing all the GUI component construction and property setting in one file, and allowing the user to only have to see/edit the application level code in another file. Likewise LINQ to SQL generates a custom DataContext child class, and the user can optionally create a 2nd file with the partial class to extend it.

C# also has partial methods which are essentially abstract methods with a compiler generated empty body. They are not virtual as you cannot call a base.method() from method(), instead you optionally implement the method and if you don't it does nothing. LINQ to SQL uses these for insert/update/delete events for each table in your database.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to