Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:10:51+00:00 2026-06-13T10:10:51+00:00

Is it possible to split a method across two files in C#? I know

  • 0

Is it possible to split a method across two files in C#? I know partial methods are there, but they seemingly cannot do this.

Here’s the scenario. I’m using an open-source library and need to add some customizations in one or more files. For example, I want to add two new fields to the class Employee and then initialize them in the InitializeFields() method of that class. Since the open-source project continues to evolve and new versions are released every now and then, I want to keep my customizations separate from the original project, to easily upgrade to newer versions of the library.

I have already split all the required classes into Orig.cs and Custom.cs using partial class syntax, and have added my custom fields in Custom.cs. Now the problem is that I have no way of splitting the InitializeFields() method, so that my custom code goes into Custom.cs file.

Please note that I cannot use inheritance to solve the problem. The open-source library would contain numerous references to Employee class and I cannot afford to change all of them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:10:54+00:00Added an answer on June 13, 2026 at 10:10 am

    When you do this, you’re compiling the library yourself, right?

    I understand you don’t want to subclass Employee, because then all the library code that does new Employee() won’t work. However, what if you rename Employee to EmployeeBase in Orig.cs, and provide the class Employee in Custom.cs? That way when the library code is compiled, new Employee() will reference your class, not the library one. Since you’re compiling the library and your customizations in the same project, you can make this substitution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my configuration : <org.springframework.version>3.1.0.RELEASE</org.springframework.version> <spring.data.mongo.version>1.0.0.RC1</spring.data.mongo.version> Is it possible to split from this
is it possible using jQuery and CSS to split a div in two, and
Possible Duplicate: Java split() method strips empty strings at the end? In Java, I'm
Is it possible to build a regexp for use with Javas Pattern.split(..) method to
Possible Duplicate: Java split() method strips empty strings at the end? The split method
Possible Duplicate: Java split() method strips empty strings at the end? we have a
I'm using this method to split some text: String[] parts = sentence.split([,\\s\\-:\\?\\!\\«\\»\\'\\´\\`\\\\\.\\\\\\/]); Which will
Possible Duplicate: A method to reverse effect of java String.split()? How do I take
Possible Duplicate: Merge Two Video files in iPhone Application I have download 40mb video
Is it possible to split a tag at lower to upper case boundaries i.e.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.