在Delphi编程中,我有一个类并将该类的实例存储在列表中,代码如下:
type
TMyClass = class
public
name: String;
old: Integer;
anx: boolean;
end;
...
function x(aList: TList): String;
var
aObj: TMyClass;
i: Integer;
begin
for i:= 1 to aList.Count do
begin
aObj := aList[i-1];
end;
end;
如何在 C# 中执行此操作?
如何在 C# 中编写
TList
等效项并让我的班级收到 TList
?
//this is the class with fields.
public class TMyClass
{
public String Name;
public int old;
public bool anx;
}
//this is the class with properties.
public class TMyClass
{
public String Name { get; set; };
public int old { get; set; };
public bool anx { get; set; };
}
public string x(List<TMyClass> list)
{
TMyClass aObj;
for(int i = 0; i++; i < list.Count)
{
aObj = list[i];
}
//NEED TO RETURN SOMETHING?
}
这是您的类和函数的翻译。但我确实相信你的函数需要返回一些东西......