1

How can i create a partial class at runtime?

Example: I have a class

public partial class A
{

}

I want to create partial of my A class at runtime from an XML file. because I don't compile my project when any change in code. I know this is little meaning less but i need this.

XOML files work for me?

Cecil Has a Name
  • 4,962
  • 1
  • 29
  • 31
tobias
  • 1,502
  • 3
  • 22
  • 47
  • 3
    Can you elaborate more on your question please? Are you trying to compile code at runtime? – Justin Dec 11 '09 at 14:48
  • 1
    This question sounds like you have a misunderstanding of what a partial class is. If you explain a bit about what you're trying to do, you may get answers that can explain a bit more about how to solve the issue. – Beska Dec 11 '09 at 14:50
  • Even after the edit, I'm confused as to what you're trying to do. – Jon Seigel Dec 11 '09 at 15:08

3 Answers3

11

The point of partial classes is to be able to define parts of it in different source files. In the end, after compilation, what you have is a regular class, indistinguishable of any other. So there is not such a thing as "instantiating a partial class".

Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
7

The partial keyword is used to separate a class across multiple code files. The compiler merges them together into a single class.

MSDN: Partial Class Definitions

Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
4

You can't.

A partial class doesn't exist in the CLR. It's more of a Visual Vtudio trick than anything else.

hometoast
  • 11,522
  • 5
  • 41
  • 58