Delphi转C# [英] Delphi to C#

查看:197
本文介绍了Delphi转C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是C#的新手,试图转换以下Delphi代码;



 TStockItemSize = class(TRemotable)
private
FId:string;
FName:string;
发布
属性id:string读取FId写入FId;
属性名称:字符串读取FName写入FName;
结束;

TStockItemSizes = TStockItemSize的数组;





你能告诉我如何申报TStockItemSizes类型C#?

感谢您的帮助。

解决方案

您好,



我假设你正在寻找定义TStockItemSize类,然后在你的TStockItem类中使用它。在这种情况下,你会做这样的事情:

公共类StockItemSize:Remotable //其中Remotable是祖先类... 
{
private string id;
public string Id
{
get
{
return(id);
}
设定
{
id = value;
}
}

私人字符串名称
公共字符串名称
{
get
{
return(name );
}
设置
{
name = value;
}
}

}
公共类StockItem
{
//构造函数...
public StockItem()
{
sizes = new List< StockItemSize>();
}
//析构函数...
~SstockItem()
{
sizes.Clear;
}

private List< StockItemSize>大小;
public List< StockItemSize>尺寸
{
获得
{
返回尺寸;
}
}

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





希望这会有所帮助:)


你就是这样做的。列表与LT; TStockItemSize> TStockItemSizes =新列表< TStockItemSize>();



如果你不能这样做,你就知道没有C#,也不应该做这个任务。考虑付给C#程序员为你做这件事。


Hello Christian,

感谢您的回复。

你知道字面意思没有C#我说过我是C#的新手。

只是为了让这一点更清楚。

我有以下内容; (也许应该早点发布)



 TStockItem = class(TRemotable)
private
FSizes:TStockItemSizes ;
发布

属性大小:TStockItemSizes读取FSizes写入FSizes;
end;





所以TStockItemSizes是一种类型。在上面的例子中,TStockItemSizes是否开始声明为变量?如何声明为一个类型,以便它可以像上面一样使用?或者我在这里偏离轨道而没有任何意义?

再次感谢


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.

解决方案

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 :)


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.


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


这篇关于Delphi转C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆