使用部分类 [英] Using partial classes

查看:143
本文介绍了使用部分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用的内存,性能等情况下,部分类的开销?

Is there any overhead using partial classes in case of memory, performance etc?

如果我们创建一个部分类,我们可以确定类是否是局部的或者不使用反射

If we create a partial class can we identify whether the class was partial or not using reflector??

推荐答案

没有。它们被编译到相同的IL,好像他们是不偏。这是一个的纯粹的编译时的事情 - 在CLR甚至不知道他们有没有偏

No. They are compiled to the same IL as if they weren't partial. It's a purely compile-time thing - the CLR doesn't even know that they were ever partial.

请注意,与的 < A HREF =http://msdn.microsoft.com/en-us/library/vstudio/6b0scde8.aspx>部分方法 的引入C#3,该方法不甚至可以发出在IL除非它的一个文件的方式实现。 。无论是电话和申报由编译器获得剥夺了

Note that with partial methods introduced into C# 3, the method doesn't even get emitted in the IL unless it's implemented in one of the files. Both the calls and the declaration get stripped out by the compiler.

这是可能的,它会一毫秒的潜移默化的分数,当然,编译器变慢:)

It's possible that it'll slow down the compiler an imperceptible fraction of a millisecond, of course :)

这篇关于使用部分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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