Questions tagged [partial-methods]

In C#, a partial method has an optional implementation. Without an implementation, the compiler will remove the method and all calls to it.

In , partial methods are methods defined with the partial modifier.

Partial methods can be defined as part of a partial class or struct, and have an optional implementation. If there is no implementation in any of the parts of the class or struct, the compiler will remove this method and any calls to it.

References

28 questions
2
votes
2 answers

Calling a method when another method is called

This might be a stupid question, but here goes. I have the following problem: public class MyBaseClass { public void SomethingAwesome() { //Awesome stuff happens here, but only when the Something() method //is called in the…
Mike Eason
  • 9,525
  • 2
  • 38
  • 63
2
votes
2 answers

Workaround for VB.NET partial method using CodeDom?

I know CodeDom doesn't support partial methods, but is there a workaround? I found a workaround for C#, but I need one for VB.NET. Thanks.
adam0101
  • 29,096
  • 21
  • 96
  • 174
2
votes
2 answers

Do unimplement partial methods get replaced with null when used as a delegate parameter?

So i have 2 distinct methods. one is a normal method void DoSomething(delegate x) { foreach(......) { x(); } } the other is a partial but unimplemented one partial void DoWorkInForEach(); when i call my first method like…
Freeman
  • 5,691
  • 3
  • 29
  • 41
2
votes
1 answer

How do I modify values of my object in partial class of EntityDataModel

I have a EntityDataModel generated from my database (Visual Studio 2010, asp.net 4.0, c#). I am trying to use a partial class associated to an entity class to perform some business logic (in this case check a phone number field and remove…
NDUF
  • 687
  • 6
  • 14
1
vote
3 answers

Calling Partial Methods in C#

i was recently digging on new partial methods in c#3.0, i understood the use of partial class, that it could be chunked into multiple file one contain the definition and other declaration, but i wanted to know,i created a partial class like…
Abbas
  • 4,948
  • 31
  • 95
  • 161
1
vote
1 answer

How do I provide partial method as an optional Action

I am migrating some code and have nicely formatted Look-up Tables but they have to be converted into archaic structures for use because of backward compatibility. I have a GetLookupTable() method which goes and gets a list of SelectItemList, all off…
David Cruwys
  • 6,262
  • 12
  • 45
  • 91
1
vote
2 answers

Why can't we write partial Functions?

Let us suppose that we have a Partial Class called Foo, like this: Partial Public Class Foo Partial Private Sub Bar(lorem As String) End Function Private Sub Bar(lorem As String) 'Do something End Function End Class This is…
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
1
vote
0 answers

Is there anyway to implement a partial method using a base implementation (inheritance)?

I'm using LinqToSql in one of my projects and I want a bunch of tables to do something when they are loaded. Each table implements a partial class an inherits a base class that does some business logic. My code looks something like this: public…
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99
1
vote
2 answers

Partial methods in Orchard custom modules

We've developed a DSL to help in coding Orchard custom modules. In the generated driver's Editor method, we're using partial methods to allow for the programmer to override the genrated code behavior, if needed. At runtime, though, we're getting an…
0
votes
2 answers

is it possible to update values on changed event using Entity Frameworks partial methods

I was wondering how to change input values when using the Entity Framework. Till now I'm using selfmade custom classes which I transform to entity classes. I think I'm doubling the work i have to do. In the custom class I transform the incomming…
Luuk Krijnen
  • 1,180
  • 3
  • 14
  • 37
0
votes
0 answers

Partial Methods - Multiple implementing declarations alternate solution?

I am currently trying to understand the purpose of partial methods as, the way in which i was hoping to use them was like an event. Example.cs public partial class Example { partial void LoadData(); public void Example() { …
A.Mills
  • 357
  • 3
  • 16
0
votes
0 answers

LINQ to SQL Partial method does not override auto generated method

I am looking to get create a partial method to override an auto generated method in linq to sql. From my reading i assume that my method should be used over the auto generated method. if that is the case why am i getting this error? "Type X already…
Timmy Fuller
  • 75
  • 1
  • 10
-6
votes
1 answer

Partial Methods in C# and parameters

Ref and out can change the behavior of function parameters. Sometimes we want the actual value of a variable to be copied as the parameter. Other times we want a reference. These modifiers affect definite assignment analysis. My question is: can…
Tony
  • 1,177
  • 6
  • 18
  • 31
1
2