• Reflector反编译结果的T?相对应的为Nullable(Of T)


        1、用Reflector反编译时,有时候会产生T?,这时候可用Nullable(Of T)代替,通过HasValue来判断是否有值,而Value能获取T的值。

        2、用Reflector反编译时,有时候会产生

        Try
            ...
        Catch X As Object
            ...
        End Try

        这时候应该用Exception代替Object,表示异常。

        3、用Reflector反编译时,有时候会产生

        Public Custom Event X As EventHandler
            AddHandler(ByVal value As EventHandler)
                Dim handler2 As EventHandler
                Dim x As EventHandler = Me.X
                Do
                    handler2 = x
                    Dim handler3 As EventHandler = DirectCast(Delegate.Combine(handler2, value), EventHandler)
                    x = Interlocked.CompareExchange(Of EventHandler)((Me.X), handler3, handler2)
                Loop While (Not x Is handler2)
            End AddHandler
            RemoveHandler(ByVal value As EventHandler)
                Dim handler2 As EventHandler
                Dim x As EventHandler = Me.X
                Do
                    handler2 = x
                    Dim handler3 As EventHandler = DirectCast(Delegate.Remove(handler2, value), EventHandler)
                    x = Interlocked.CompareExchange(Of EventHandler)((Me.X), handler3, handler2)
                Loop While (Not x Is handler2)
            End RemoveHandler
        End Event

         Private X As EventHandler

        这时候应该用去掉Custom,并删除AddHandler和RemoveHandler两个过程,以及声明。

        4、用Reflector反编译时,有时候会产生

        Public Property X As Integer
            Get
            Set (ByVal value As Integer)
        End Property

        <CompilerGenerated> _
        Private <X>k__BackingField As Integer

        这时候应该删除Get和Set语句,并删除编译产出的变量声明,或者补足Get和Set语句。

  • 相关阅读:
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    Java之内部类
    Java之回调模式和ThreadLocal
  • 原文地址:https://www.cnblogs.com/tulife/p/2217693.html
Copyright © 2020-2023  润新知