domingo, septiembre 26, 2004

Mono Days

Last thursday I met Miguel de Icaza at Mexico city, where he gave a conference about the advantges of the use of Linux (and particularly the Novell version) over the use of other OS.

His conference was part of a small Novell and Hp event surrounding Linux, and the mentioned event took place at a luxurious hotel where a lot of people had chance to talk to Miguel not only about computers, but abou politics and economics.

After the event we had lunch and I could met also Mancha, Cesar Octavio López Nataren ( the Mono JScript guy) and other Miguel's friends.

Just as always, I must say that I admire Miguel a lot and I'm happy to being working in the same project with him.

Properties Access Modifiers
Currently I'm implementing a new feature that is part of the C# 2.0 specs is the posibility to have your properties accessors with different access scopes. Today, a property is declared as follows:

public int Property {
get {
return val;
}
set {
val = value;
}
}

This generates two methods, set_Property and also get_Property, that work very smoothly. It is important to note that both methods will inherit all the acess modifiers indicated in th Property declaration, so in the previous example the methods would be described as:

public int get_Property ( );
public void set_Property (int value);


However, sometimes it would be great if the methods need to have different acess modifiers each one. For example, when you have an abstract class that exposes both get and set accessors, but want to declare the get as public, and the set as protected (thus reserved to the subclasses), wou will have to avoid declaring the set accessor and expose it in another way.

With this new feature found int C# 2.0, no more problems of this kind. Now is possible to declared one of the two accessors with different access modifier than the Property itself:

public int Property {
get {
return val;
}
protected set {
val = value;
}
}

Finally, the accessors methods would be described then as:

public int get_Property ( );
protected void set_Property (int value);

Which will be clearer and prettier than before.

4 comentarios:

Mauricio dijo...

Hi, now you appear in http://planeta.monohispano.org in my blog.

Cheers,
Mauricio

Gordon dijo...

Hello, your blog is informative. I have a linux server related website, please visit and hope that it is helpful to you

Roberto Iza Valdes dijo...
Este blog ha sido eliminado por un administrador de blog.
Roberto Iza dijo...
Este comentario ha sido eliminado por el autor.