What is the difference in below two lines of code for getting the
Schema.DescribeSObjectResult
?// Get the sObject describe result for the Account object Schema.DescribeSObjectResult dsr = Account.sObjectType.getDescribe(); Schema.DescribeSObjectResult d = Schema.SObjectType.Account;
Answer
There is no difference except the latter becomes less verbose when you drop the optional Schema.
portion. Every time you type:
SObjectType.Account
instead of:
Account.sObjectType.getDescribe()
you save 14 characters.
Here are some examples of the flexibility you have here.
Schema.SObjectType accountType = Schema.Account.sObjectType;
accountType = Account.sObjectType;
DescribeSObjectResult accountDescribe = SObjectType.Account;
accountDescribe = Schema.Account.sObjectType.getDescribe();
accountDescribe = accountType.getDescribe();
Attribution
Source : Link , Question Author : s_saiyan , Answer Author : Adrian Larson