图生活吧

博客园 首页 新随笔 联系 订阅 管理

    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语句。

posted on 2011-10-19 15:10  图生活吧  阅读(264)  评论(0编辑  收藏  举报