Ver Mensaje Individual
  #42  
Antiguo 27-04-2013
Avatar de RONPABLO
[RONPABLO] RONPABLO is offline
Miembro Premium
 
Registrado: oct 2004
Posts: 1.514
Reputación: 21
RONPABLO Va por buen camino
Cita:
Empezado por rretamar Ver Mensaje
(igual sigo prefiriendo la sintaxis de Object Pascal, la encuentro mucho más amigable "programación para seres humanos" ).

Yo tambien la prefiero pero estas dos cosas de C# sería bueno tenerlas en Delphi para mi gusto.
1. el asignar propiedades.
Código:
En Delphi
type MyClass = class(tObject)
  private
      fMyProp : integer;
      function GetMyProp: integer;
      procedure SetMyProp(const Value: integer);
  public
      property MyProp : integer read GetMyProp write SetMyProp;
  end;
  
  function MyClass.GetMyProp: integer;
      begin
      result:= max(fMyProp,0);
      end;
  
  procedure MyClass.SetMyProp(const Value: integer);
      begin
      if Value >= 0 then
         fMyProp:= Value;
      end;
  



En C#


Código:
public class MyClass
{
    private int myProp = 0;
    public  int MyProp
        {
        get { return Math.Max(myProp, 0); }
        set { if (value > 0)
                  myProp = value; }
        }
}

2. try catch con finally
en C#
Código:
try
        {
            throw     New MyException("Error occurred in C#");
        }
        catch(MyException) 
        { 
            HandleMyException(); 
        }
        finally
        {
            CleanUp(); 
        }
Esto en delphi requiere de abrir dos try, el primero con el finally y el segundo con el catch
__________________
"Como pasa el tiempo..... ayer se escribe sin H y hoy con H"
Responder Con Cita