Tech Off Post

Single Post Permalink

View Thread: Code re-use in Visual C# .NET Projects
  • User profile image

    There are two approaches here.
    The object-oriented approach is to create the form just once, in one project, and reference it from the other two projects. This way you just instantiate it twice. You describe it as overkill, but I don't think it's that horrible. Certainly neater, since you won't have the same class defined twice in different place in the binary.

    The second approach, if you just want to share the same source file for two projects, is to link it to two projects. When you do Add Existing Item, note the little dropdown arrows on the Open button - this allows you to do a Link instead of creating a new copy of the source file.

    Do note that this has a tendency of messing with VSS and other source-control systems, but nothing that can't be managed.