The new automatic properties get rid of
public string LastName {and replace with the much more succinct,
get {
return _lastName;
}
set {
_lastName = value;
}
}
public string LastName { get; set; }
Which is a backing into the Ruby attr_accessor function.
attr_accessor :last_name
The main difference is that in Ruby attr_accessor isn't part of the core language, it's just a helper function that anyone could add.
Also the new object initializers,
Person person = new Person { FirstName="Scott", LastName="Guthrie", Age=32 };
Look so similiar to the Ruby style of passing in a hash of values.
my_func (FirstName=>"Scott", LastName=>"Guthrie", Age=>32)
These are great new changes in C# as we travel towards the Ruby Way.
No comments:
Post a Comment