Archetype.Examples.PersonExamples.UsingModelObjectAsDynamic C# (CSharp) Метод

UsingModelObjectAsDynamic() приватный Метод

private UsingModelObjectAsDynamic ( ) : void
Результат void
        public void UsingModelObjectAsDynamic()
        {
            dynamic person = new Person();
            // The cast to the interface will work
            INotifyPropertyChanges inpc = person;
            inpc.PropertyChanged +=
                    ( sender, args ) => Console.WriteLine( "The field {0} has changed.", args.PropertyName );
            inpc.PropertyChanging +=
                    ( sender, args ) => Console.WriteLine( "The field {0} is changing.", args.PropertyName );
            // We have full IntelliSense when working with person.
            // but now accessing .Name looses IntelliSense
            person.Name = "Inigo Montoya";
        }