Questions tagged [partial-classes]

With this keyword classes can be split into multiple definitions, but it compiles into one class.

With this keyword, classes can be split into multiple (mostly two) definitions, but the code compiles into one run-time class.

References

441 questions
6
votes
2 answers

Event Handler located in different class than MainWindow

So I followed the guide on the following site to restrict the characters a textbox can accept. http://www.rhyous.com/2010/06/18/how-to-limit-or-prevent-characters-in-a-textbox-in-csharp/ My problem is I can't figure out how to make the event handler…
Keven M
  • 972
  • 17
  • 47
6
votes
5 answers

Is it possible to give javascript partial class behavior like C# or monkey patching like Ruby does?

The idea behind partial classes is that you can group certain functions together. The best example of this in C# is putting control definitions in one file and the event handlers in another. In Ruby, you can use Monkey patching to replace entire…
aarona
  • 35,986
  • 41
  • 138
  • 186
6
votes
1 answer

Inheritance with Silverlight User Control Partial Classes

I am trying to allow several classes to inherit a more general Silverlight user control to avoid redundancy in my code. The classes inherit the extended control, which then inherits the User Control class. The issue I have been running into is that…
6
votes
3 answers

EF 4, how to add partial classes

I needed to extend my EF partial classes, because I want to add some functionality to able to use Oracle's sequences , however I really don't know how to use this partial class thing, I made a seperate .cs file and name it as one of my…
Musaab
  • 805
  • 2
  • 13
  • 30
6
votes
4 answers

Creating partial class in C#

I am a student and I dont know what a partial class is. The following code belongs to a partial class I automatically created the partial class: public partial class EGUI: Form { private OleDbConnection dbConn; // Connectionn object …
Mary
  • 151
  • 2
  • 5
  • 10
6
votes
1 answer

Partial classes in typescript

files.ts export class ServiceUrls { static baseUrl: string = 'http://localhost:52949/V1/'; static baseImageUrl: string = 'http://localhost:52949/'; } filess1.ts extends interface ServiceUrls{ static baseUrl: string =…
6
votes
1 answer

override a method using a partial class

I have a class formed by two partial classes. One created by ORM code generation and one for extensions. In this particular instance, I need to override one of the properties generated by the partial class because I need to do some validation on it…
Diskdrive
  • 18,107
  • 27
  • 101
  • 167
6
votes
2 answers

Entity Framework .. partial constructor

I intend to extend the constructors of some of the entities in my Entity Framework (4). However how do I ensure that my constructor is run after the model has run its. i.e. I want to ensure that the the object holds the data from the database before…
Adam
  • 291
  • 3
  • 13
6
votes
5 answers

Can i call a function defined in one partial class from another partial class. Is it possible?

I have created two partial classes for a web page. Now i have given a defination of one function say submit() that i m calling at OnSubmit event of button. But this function is not being called, the program doesnot compiles as it is not able to…
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
6
votes
4 answers

Under what conditions it is good to have a "partial class?"

When does it become a good idea to have your class separate into two .cs and have it as a partial class? Are there some signs showing that it is time to go with partial class? Thanks!
pencilCake
  • 51,323
  • 85
  • 226
  • 363
6
votes
6 answers

The type X conflicts with imported type X

In Entity Framework (Database first) I am trying to add some Data annotations to created classes. In general: I have class X created: namespace Info { using System; using System.Collections.Generic; public partial class X { …
el vis
  • 1,302
  • 2
  • 16
  • 32
6
votes
1 answer

Nested class written outside of the class

I like using private nested classes, except that they always feel so cluttered. Normally I put them in their own #region, but I would prefer them to be separate from their parent class in terms of location, and I also don't really want them in…
Dave Cousineau
  • 12,154
  • 8
  • 64
  • 80
6
votes
2 answers

FluentValidation validator not being called

I have a MVC 3 site but am using the non-MVC FluentValidation dll. I've created a validator class and in the constructor put all my RuleFors and then set an attribute on my model class…
6
votes
2 answers

Override ToString method in WCF service

This is my service generated class: public partial class MyClass : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged { } I'm…
levi
  • 3,451
  • 6
  • 50
  • 86
6
votes
4 answers

Tool to merge partial classes into one class?

Is there a tool to merge partial classes into one non-partial class? I cannot use Reflector, since I need variable names, etc. to match. EDIT: I have hundreds of partial classes I want to merge, so cut-paste is not realistic.
cm007
  • 1,352
  • 4
  • 20
  • 40