Account.sObjectType.getDescribe() vs Schema.sObjectType.Account

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;


There is no difference except the latter becomes less verbose when you drop the optional Schema. portion. Every time you type:


instead of:


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();

Source : Link , Question Author : s_saiyan , Answer Author : Adrian Larson

Leave a Comment