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?

3
  • 3
    Can you elaborate more on your question please? Are you trying to compile code at runtime? Commented Dec 11, 2009 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. Commented Dec 11, 2009 at 14:50
  • Even after the edit, I'm confused as to what you're trying to do. Commented Dec 11, 2009 at 15:08

3 Answers 3

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".

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

4

You can't.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.