在方法签名后使用密封,在类名之后使用密封可以解释一下吗 [英] sealed used after method signature, sealed used after class name ??? Can some one explain

查看:146
本文介绍了在方法签名后使用密封,在类名之后使用密封可以解释一下吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看vc ++中使用的某些托管代码,并且我已经注意到,密封是我不熟悉的一种方式.在一个实例中,在类的名称之后但在单个作用域运算符之前使用了密封.
第二个实例是在方法的签名后使用了密封.
我不确定为什么在这两个实例中都使用了密封.
我正在尝试将下面显示的代码转换为C#,但是使用密封的方法使我感到很困惑.如果有人可以解释在两种情况下如何使用密封,并且可以向我展示如何使用密封将下面所示的代码转换为C#,我将不胜感激.

下面是源代码,它是c ++文件,我正在尝试将此代码转换为C#,但是类中的密封部分和方法使我难堪.


ref class CustomList seal:System :: Collections :: Generic :: IEnumerable< LocalList ^> ;, System :: ComponentModel :: IBindingList,System :: ComponentModel :: IRaiseItemChangedEvents
{
{
.....
virtual System :: Object ^ AddNew()seal = System :: ComponentModel :: IBindingList :: AddNew
{
throw gcnew System :: NotSupportedException();
}

........
}

I am looking at some managed code used in vc++ and I have noticed that sealed is used in a way I am not familiar with. In one instance sealed is used after a class's name but before the single scope operator.
The second instance is the sealed is used after a method's signature .
I am not sure why sealed is used in either instance.
I am trying to translate the code shown below into C# but the way sealed is used has me stumped.  If someone could explain how sealed is used in both instances, and could show me how to can translate the code shown below  to C# using the seal I would appreciate it greatly.

Below is the source code which is a c++ file, I am trying to convert this code into C# but the sealed part in class and the method has me stumped.


ref class CustomList sealed : System::Collections::Generic::IEnumerable<LocalList^>, System::ComponentModel::IBindingList, System::ComponentModel::IRaiseItemChangedEvents
{
{
.....
    virtual System::Object^ AddNew() sealed = System::ComponentModel::IBindingList::AddNew
    {
        throw gcnew System::NotSupportedException();
    }

.....
}

推荐答案

我对C ++一无所知,但是如果此代码位于dll中(或者您可以将其编译为dll),则可以使用Reflector打开该dll并将其显示为C#.

hth,
Marcel
I know nothing about C++, but if this code is inside a dll (or if you can compile it into a dll) you could open the dll with Reflector and display it as C#.

hth,
Marcel


这篇关于在方法签名后使用密封,在类名之后使用密封可以解释一下吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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