InitObject() public abstract méthode

Pops a managed or native pointer off the stack and initializes the referenced type with zeros.
public abstract InitObject ( Type type ) : void
type System.Type The type the pointer on the top of the stack is pointing to.
Résultat void
 /// <summary>
 /// Emits a default value of the given type.
 /// </summary>
 /// <param name="generator"> The IL generator. </param>
 /// <param name="type"> The type of value to generate. </param>
 public static void EmitDefaultValue(ILGenerator generator, Type type)
 {
     var temp = generator.CreateTemporaryVariable(type);
     generator.LoadAddressOfVariable(temp);
     generator.InitObject(temp.Type);
     generator.LoadVariable(temp);
     generator.ReleaseTemporaryVariable(temp);
 }
Exemple #2
0
        /// <summary>
        /// Emits a default value of the given type.
        /// </summary>
        /// <param name="generator"> The IL generator. </param>
        /// <param name="type"> The type of value to generate. </param>
        public static void EmitDefaultValue(ILGenerator generator, Type type)
        {
            var temp = generator.CreateTemporaryVariable(type);

            generator.LoadAddressOfVariable(temp);
            generator.InitObject(temp.Type);
            generator.LoadVariable(temp);
            generator.ReleaseTemporaryVariable(temp);
        }