Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I am new to C#, trying to convert the following Delphi code;

TStockItemSize = class (TRemotable)
  private
    FId : string ;
    FName : string ;
  published
    property id : string read FId write FId ;
    property name : string read FName write FName ;
  end ;
  
  TStockItemSizes = array of TStockItemSize ;


Are you able to tell me how I declare the TStockItemSizes type in C#?
Thanks for the help.
Posted
Updated 7-May-18 6:18am

Hello,

I'm assuming that you are looking at defining the TStockItemSize class and then using it in your TStockItem class. In that case you would do something like this:
public class StockItemSize : Remotable // where Remotable is the ancestor class...
{
    private string id;
    public string Id
    {
        get
        {
            return (id);
        }
        set
        {
            id = value;
        }
    }

    private string name
    public string Name
    {
        get
        {
            return (name);
        }
        set
        {
            name = value;
        }
    }

}
public class StockItem
{
    // constructor...
    public StockItem()
    {
        sizes = new List<StockItemSize>();
    }
    // destructor...
    ~StockItem()
    {
        sizes.Clear;
    }

    private List<StockItemSize> sizes;
    public List<StockItemSize> Sizes
    {
        get
        {
            return sizes;
        }
    }

    public int SizeCount
    {
        get
        {
            return (Sizes.Count);
        }
    }
}


Hope this helps :)
 
Share this answer
 
v4
You just do it. List<TStockItemSize> TStockItemSizes = new List<TStockItemSize>();

If you can't do that, you know literally no C#, and should not be doing this task. Consider paying a C# programmer to do it for you.
 
Share this answer
 
v3
Comments
rickyjos 18-Aug-10 6:07am    
OK, I think I get it now. I don't need to declare the TStockItemSizes type in C#. I can just do something like the following directly in my class??

TStockItemSize[] Sizes { get; set; }

Cant do that in delphi...
Hello Christian,
Thanks for the reply.
"you know literally no C#" I did say "I am new to C#".
Just to make this a bit clearer.
I have the following; (maybe should have posted it earlier as well)

TStockItem = class (TRemotable)
  private
    FSizes  : TStockItemSizes ;
  published
    
    property sizes  : TStockItemSizes read FSizes write FSizes ;
end;


So TStockItemSizes is a type. In your example above, is TStockItemSizes begin declared as variable? How do I declare as a type so it can be used as above? Or am I way off track here and making no sense?
Thanks again
 
Share this answer
 
Comments
Toli Cuturicu 18-Aug-10 6:40am    
Reason for my vote of 1
fake answer
rickyjos 22-Aug-10 21:55pm    
What is a "fake answer"? Is it because I replied to Christians post by doing it in the add answer box, not the add comment box??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900