I have a partial class that is split over two namespaces. The problem is that if I have an interface implemented on one of the partials, it is not recognized on the counterpart partial class. For example, I would expect the below to return true for being recognized as ILastModified
(C# fiddle at http://ideone.com/heLDn0):
using System;
using MyNamespace.One;
public class Test
{
public static void Main()
{
var item = new Product();
Console.WriteLine(item is ILastModified); //RETURNS FALSE??!
}
}
interface ILastModified
{
DateTime LastModified { get; set; }
}
namespace MyNamespace.One
{
public partial class Product
{
public int ID { get; set; }
}
}
namespace MyNamespace.Two
{
public partial class Product : ILastModified
{
public DateTime LastModified { get; set; }
}
}
You cannot have a partial class in two different namespaces. The compiler treats those as two different classes.