Adam Tegen Adam Tegen - 3 years ago 135
C# Question

Error with C# Partial classes

I am using partial classes to split some functionality between 2 files, but I am getting an error. What am I doing wrong?

A1.cs:

private partial class A
{
private string SomeProperty { get { return "SomeGeneratedString"; } }
}


A2.cs:

private partial class A
{
void SomeFunction()
{
//trying to access this.SomeProperty produces the following compiler error, at least with C# 2.0
//error CS0117: 'A' does not contain a definition for 'SomeProperty'
}
}

Answer Source

Are the two partial classes in the same namespace? That could be an explanation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download