PDA

View Full Version : معادل کدهای #C در دلفی



کامروا
چهارشنبه 27 دی 1391, 10:22 صبح
سلام

معادل کدهای زیر در زبان دلفی به چه شکل هست؟

1- کد #C :
int[] test = { 2, 45, 3, 23, 23, 4, 2, 1, 1, 1, 1, 23, 45, 45, 45 };
int count = test.Count(i => i == test.Max());

2- کد #C :
public static void Initial()
{
//statements
}

و آیا Generic Array ها در دلفی دارای تابع Add برای اضافه کردن مقدار به آخر آرایه هستند؟

سپاس

Felony
چهارشنبه 27 دی 1391, 10:54 صبح
1-


var
i, Max, Count: Integer;
begin
Count:= 0;
Max:= test[0];
for i := Low(test) to High(test) do
if (test[i] > Max) then
Max := test[i];

for i := Low(test) to High(test) do
if (test[i] = Max) then
Inc(Count);

ShowMessage(IntToStr(Count));
end;

2- در بخش Public کلاس مورد نظر :


procedure Initial;
begin

end;

3- خیر ولی میشه با طراحی یک کلاس پیادش کرد .

کامروا
چهارشنبه 27 دی 1391, 20:57 عصر
ممنون.

نحوه ساختن Clone به چه شکل هست ؟

public Person ShallowCopy()
{
return (Person)this.MemberwiseClone();
}
و
public Person DeepCopy()
{
Person other = (Person) this.MemberwiseClone();
other.IdInfo = new IdInfo(this.IdInfo.IdNumber);
return other;
}

Felony
پنج شنبه 28 دی 1391, 06:47 صبح
http://www.codeproject.com/Articles/508681/Deeppluscopyingplus-cloning-plusobjectsplusinplusD
http://delphi.about.com/od/course/a/delphi_oop20.htm