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 35063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:10:35+00:00 2026-05-10T14:10:35+00:00

I have read about partial methods in the latest C# language specification , so

  • 0

I have read about partial methods in the latest C# language specification, so I understand the principles, but I’m wondering how people are actually using them. Is there a particular design pattern that benefits from partial methods?

  • 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. 2026-05-10T14:10:36+00:00Added an answer on May 10, 2026 at 2:10 pm

    Partial methods have been introduced for similar reasons to why partial classes were in .Net 2.

    A partial class is one that can be split across multiple files – the compiler builds them all into one file as it runs.

    The advantage for this is that Visual Studio can provide a graphical designer for part of the class while coders work on the other.

    The most common example is the Form designer. Developers don’t want to be positioning buttons, input boxes, etc by hand most of the time.

    • In .Net 1 it was auto-generated code in a #region block
    • In .Net 2 these became separate designer classes – the form is still one class, it’s just split into one file edited by the developers and one by the form designer

    This makes maintaining both much easier. Merges are simpler and there’s less risk of the VS form designer accidentally undoing coders’ manual changes.

    In .Net 3.5 Linq has been introduced. Linq has a DBML designer for building your data structures, and that generates auto-code.

    The extra bit here is that code needed to provide methods that developers might want to fill in.

    As developers will extend these classes (with extra partial files) they couldn’t use abstract methods here.

    The other issue is that most of the time these methods wont be called, and calling empty methods is a waste of time.

    Empty methods are not optimised out.

    So Linq generates empty partial methods. If you don’t create your own partial to complete them the C# compiler will just optimise them out.

    So that it can do this partial methods always return void.

    If you create a new Linq DBML file it will auto-generate a partial class, something like

    [System.Data.Linq.Mapping.DatabaseAttribute(Name='MyDB')] public partial class MyDataContext : System.Data.Linq.DataContext {     ...      partial void OnCreated();     partial void InsertMyTable(MyTable instance);     partial void UpdateMyTable(MyTable instance);     partial void DeleteMyTable(MyTable instance);      ... 

    Then in your own partial file you can extend this:

    public partial class MyDataContext {     partial void OnCreated() {         //do something on data context creation     } } 

    If you don’t extend these methods they get optimised right out.

    Partial methods can’t be public – as then they’d have to be there for other classes to call. If you write your own code generators I can see them being useful, but otherwise they’re only really useful for the VS designer.

    The example I mentioned before is one possibility:

    //this code will get optimised out if no body is implemented partial void DoSomethingIfCompFlag();  #if COMPILER_FLAG //this code won't exist if the flag is off partial void DoSomethingIfCompFlag() {     //your code } #endif 

    Another potential use is if you had a large and complex class spilt across multiple files you might want partial references in the calling file. However I think in that case you should consider simplifying the class first.

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

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you need to select FROM something (a table, say) before… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer you can measure your FPS if you want ... you… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer Done by hand: L ::= { L } | {… May 12, 2026 at 12:48 am

Related Questions

In a web application that I have run across, I found the following code
I have read lots of information about page caching and partial page caching in
How can I show relations between ToDo-lists? I am using Devtodo. I will give
I have a fairly specific question about concurrent programming in C. I have done

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.