Search code examples
visual-studio-2008partial-classes

Partial Class - Visual Studio 2008


Is there a possibility to create partial classes that are grouped in the Solution Explorer like VS does it with code behind classes (eg. Default.aspx and Default.aspx.cs).

I would like to create MyClass.cs and MyClass.partial.cs and they should not be shown as 2 seperate files in the Solution explorer.


Solution

  • I've not seen a way to do this within Visual Studio itself, but it is possible to do it by editing the .csproj file. You need to find the place where the file you want to show up under the other file is in the proj file and add a element with the content set to the name of the file you want to be dependent upon.

    example:

    <Compile Include="MyFile.g.cs">
        <DependentUpon>MyFile.cs</DependentUpon>
    </Compile>