´ñ±Û : 3 °³
Çѱ¹ µ¨ÆÄÀÌ µ¿È£È¸ µ¨¸¶´ç
³´¾Å
(¹ÚÁ¤¼ø)
 
http://www.delphipages.com/forum/showthread.php?t=170787 À» Âü°íÇϸé

ÀÌ°ÍÀº µÇ°í...

procedure TForm1.Button1Click(Sender: TObject);
var
  s:string;
begin
  s := '10001';
  ComboBox1.Items.AddObject('a',TObject(s) );
  s := '10002';
  ComboBox1.Items.AddObject('b',TObject(s) );
  s := '10003';
  ComboBox1.Items.AddObject('c',TObject(s) );
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  label1.Caption := String( ComboBox1.Items.Objects[ComboBox1.ItemIndex] );
end;


ÀÌ°ÍÀº ¾ÈµÇ¿ä...

procedure TForm1.Button1Click(Sender: TObject);
begin
  ComboBox1.Items.AddObject('a',TObject('10001') );
  ComboBox1.Items.AddObject('b',TObject('10002') );
  ComboBox1.Items.AddObject('c',TObject('10003') );
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  label1.Caption := String( ComboBox1.Items.Objects[ComboBox1.ItemIndex] );
end;


https://www.thoughtco.com/store-a-string-or-an-object-1058392 Âü°í(±¸±Û¹ø¿ª ÀÌ¿ëÇϸ頵˴ϴÙ. ^^) ÇÏ¿© ¿Ö ¾ÈµÇ´ÂÁö... ÀÌÀ¯¸¦ ºÙÀÌÀÚ¸é...

" A direct typecast from an integer to an object is made above. The "AObject" parameter is actually the 4-byte pointer (address) of the object added. Since in Win32 an integer occupies 4 bytes - such a hard cast is possible. "


s := '10001';
  ComboBox1.Items.AddObject('a',TObject(s) );

ÀÌ°ÍÀº ¹®ÀÚ¿­ÀÇ ÁÖ¼Ò°¡ TObject ¿¡ Àü´ÞµÇ´Â °ÍÀÌ°í?


ComboBox1.Items.AddObject('a',TObject('10001') );
Àº Çüº¯È¯À» ½ÃµµÇϴ °Í? ( stringÀ» 4byte Integer·Î typecast ¾ÈµÇ¹Ç·Î... )

À§ ¿¡°ÍÀ» ±×³É ³» »ý°¢ÀÔ´Ï´Ù. °ËÁõÀÌ ÇÊ¿äÇÕ´Ï´Ù~. 
2019-05-23 ¿ÀÈÄ 10:33:39
³´¾Å
(¹ÚÁ¤¼ø)
 
[¿äÁ¡]
TObject() ÀÇ ¸Åº¯º¯¼ö(parameter)´Â °´Ã¼ÀÇ 4-byte pointer (address)  ÀÌ´Ù.

Á¤¼öº¯¼ö¿¡ ¹®ÀÚ¿­À» ¸ø ³Ö´Â °Í°ú °°ÀÌ, 4-byte pointer º¯¼ö¿¡ ¹®ÀÚ¿­À» ¸ø ³ÖÀ¸¹Ç·Î ¿¡·¯.

TObject('10001')   //¿¡·¯¹ß»ý


s := '10001';    // ¸Þ¸ð¸®¿¡ ¹®ÀÚ¿­ »ý¼º, ¹®ÀÚ¿­ÀÇ Æ÷ÀÎÅÍ ÁÖ¼Ò°¡ s 
TObject(s);    // TObject ¸Å°³º¯¼ö¿¡ ¹®ÀÚ¿­ ÁÖ¼Ò Àü´Þ


String( ComboBox1.Items.Objects[ComboBox1.ItemIndex] )
ÀÌ°ÍÀº Çüº¯È¯À» ¶æÇϴ °ÍÀÌ ¾Æ´Ï°í Æ÷ÀÎÅÍÀÇ Çü(Type)ÀÌ string ÀÓÀ» ¾Ë·Á Áִ °Í.

C¾ð¾îÀÇ Æ÷ÀÎÅÍ¿¡¼­ Æ÷ÀÎÅÍ ¿¬»êÀ» º¸¸é, Æ÷ÀÎÅ͠ŸÀÔ¿¡ µû¶ó Æ÷ÀÎÅÍ ÁÖ¼Ò ¿¬»êÀÌ ´Ù¸¥ °Í...



Á¦°¡ °øºÎ°¡ ¸¹ÀÌ µÇ³×¿ä... °¨»çÇÕ´Ï´Ù. 
2019-05-23 ¿ÀÈÄ 11:54:57
lµ¨ÆÄÀÌlÃʵùl
(ÀåÁø¿µ)
 
³´¾Å´Ô °¨»çÇÕ´Ï´Ù ´öºÐ¿¡ ÀúµÎ Çϳª ¶Ç ¹è¿ö°¡³×¿ä!~

Á¤¸»°¨»çÇÕ´Ï´Ù^^ 
2019-05-24 ¿ÀÈÄ 5:23:41