• sonu
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

hi,

please find the below lines of code

 

sObject s=new Account[select id,name from Account where name like 'test%'];

ID i=s.id;//valid

String name=s.name//invalid

 

please correct me if i am wrong, why the second statement is invalid and first statement is valid because as far as i knows that sObject holds the state and behaviour of all the concrete objects here sObject is generic object and Account object is concrete object.

please provide the detailed solution that why we can not access the id field using sObject reference i.e 's'

 

Thanks in advance

  • May 23, 2012
  • Like
  • 0