Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 07-12-2007
Avatar de jhonny
jhonny jhonny is offline
Jhonny Suárez
 
Registrado: may 2003
Ubicación: Colombia
Posts: 7.058
Poder: 30
jhonny Va camino a la famajhonny Va camino a la fama
Acabo de probar el siguiente codigo que encontre en http://www.elguille.info/NET/cursoCS.../Entrega12.htm y verifique que sigue funcionando dicho servicio:

Código:
using System;

using System.Collections;

 

namespace IndizadorLibros

{

    class Libro

    {

        private ArrayList capitulos=new ArrayList();

 

        public object this[int indice]

        {

            get

            {

                if (indice >= capitulos.Count || indice < 0)

                    return null;

                else

                    return capitulos[indice];

            }

            set

            {

                if (indice >= 0 && indice < capitulos.Count)

                    capitulos[indice]=value;

                else if (indice == capitulos.Count)

                    capitulos.Add(value);

                else

                    throw new Exception("No se puede asignar a este elemento");

            }

        }    

    

        public int NumCapitulos

        {

            get

            {

                return capitulos.Count;

            }

        }

    }

 

    class IndizadorLibrosApp

    {

        static void Main()

        {

            Libro miLibro=new Libro();

 

            miLibro[0]="La psicología de la musaraña";

            miLibro[1]="¿Puede una hormiga montar en bicicleta?";

            miLibro[1]="Un pedrusco en manos de Miró es un Miró";

 

            for (int i=0;i<miLibro.NumCapitulos;i++)

                Console.WriteLine("Capitulo {0}: {1}",i+1,miLibro[i]);

 

            string a=Console.ReadLine();

        }

    }

}

Me lo ha convertido en esto:

Código Delphi [-]
//------------------------------------------------------------------------------
// 
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.2407
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// 
//------------------------------------------------------------------------------

unit IndizadorLibros;

interface

type
  Libro = class
  strict private
    capitulos: ArrayList;
  public
    function get_this(indice: Integer): System.Object;
    function get_NumCapitulos: Integer;
    procedure set_this(indice: Integer; Value: System.Object);
    property this[indice: Integer]: System.Object read get_this write set_this;
    property NumCapitulos: Integer read get_NumCapitulos;
  end;
  
  
  IndizadorLibrosApp = class
  strict private
    class procedure Main;static; 
  end;
  
implementation

{$AUTOBOX ON}
{$HINTS OFF}
{$WARNINGS OFF}

function Libro.get_this(indice: Integer): System.Object;
begin
  if ((indice >= Self.capitulos.Count) or (indice < 0)) then
    begin
      Result := nil;
      Exit;
    end
  else
    begin
      Result := Self.capitulos[indice];
      Exit;
    end;
end;

function Libro.get_NumCapitulos: Integer;
begin
  Result := Self.capitulos.Count;
end;

procedure Libro.set_this(indice: Integer; Value: System.Object);
begin
  if ((indice >= 0) and (indice < Self.capitulos.Count)) then
    Self.capitulos[indice] := value
  else
    if (indice = Self.capitulos.Count) then
      Self.capitulos.Add(value)
    else
      raise Exception.Create('No se puede asignar a este elemento');
end;

class procedure IndizadorLibrosApp.Main;
var
  a: string;
  i: Integer;
  miLibro: Libro;
begin
  miLibro := Libro.Create;
  miLibro[0] := 'La psicolog?a de la musara?a';
  miLibro[1] := '?Puede una hormiga montar en bicicleta?';
  miLibro[1] := 'Un pedrusco en manos de Mir? es un Mir?';
  i := 0;
  while (i < miLibro.NumCapitulos) do
  begin
    Console.WriteLine('Capitulo {0}: {1}', (i + 1), miLibro[i]);
    /*PostInc*/;
  end;
  a := Console.ReadLine;
end;

end.
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!"

http://www.purodelphi.com/
http://www.nosolodelphi.com/

Última edición por jhonny fecha: 07-12-2007 a las 22:17:42.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Arbol genealógico de Lenguajes de programación basti Noticias 5 03-10-2007 21:14:05
De todos los lenguajes que hay... REHome .NET 2 28-08-2007 07:40:23
Rating o Estadisticas de Uso de los Lenguajes de Programacion Ingeniero Debates 14 15-03-2007 20:48:05
Lenguajes de programación Isaac Debates 16 27-02-2004 05:28:21


La franja horaria es GMT +2. Ahora son las 07:52:25.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi