System.Reflection.Emit.ILGenerator.ThrowException C# (CSharp) Method

ThrowException() public method

public ThrowException ( System excType ) : void
excType System
return void
        public virtual void ThrowException(System.Type excType) { }
        public virtual void UsingNamespace(string usingNamespace) { }

Usage Example

示例#1
0
        public static void EmitThrowException <T>(this ILGenerator il, string s = null) where T : Exception
        {
            var invalidcast = typeof(T);

            il.Emit(OpCodes.Ldstr, s ?? "message");
            il.Emit(OpCodes.Newobj, invalidcast.GetConstructor(new[] { typeof(string) }));
            il.ThrowException(invalidcast);
        }
All Usage Examples Of System.Reflection.Emit.ILGenerator::ThrowException