有没有办法为嵌入类创建一个局部类? [英] Is there any way to create a partial class for embeded classes?

查看:86
本文介绍了有没有办法为嵌入类创建一个局部类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家



我需要为创建一个部分类System.Exception



Hello experts

I would need to create a partial class for System.Exception

namespace System
{
    public partial class Exception
    {
        public void Something()
        {
            //...
        }
    }
}





不幸的是,它不接受这部分真正的 System.Exception



我不打算创建一个扩展方法。



你认为有办法创建一个部分类?





谢谢



unfortunately, it does not accept that as a partial of the real System.Exception

I do not plan to create an extended method.

Do you think there is a way to create a partial class?


Thank you

推荐答案

//**1
namespace System
{
   //This is not a partial class
    public class Exception : ISerializable, _Exception
    {
    }
}
1.you can not create a partial class of Exception becoz Exception is not a partial   

2.Your Exception class  means your_projectname.System.Exception which is not     equals to System.Exception 

3.All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules.


这篇关于有没有办法为嵌入类创建一个局部类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆