What is the difference between
address(this).balance in solidity contracts?
this represents a "contract instance" object for the current contract. The
balance function is part of the "address" object. You used to be able to do
this.balance because solidity would allow implicit access to the address functions through the contract instance object.
However, as of Solidity 0.4.22, the recommended practice is to use
address(this).balance which explicitly converts
this (the current contract instance) to an
In Solidity 0.5.0,
this.balance will be explicitly forbidden, and you will be required to explicitly convert to the address object before you can access it's functions.
You may find code using the older syntax due to historical practices, but you should use the modern syntax for any new contracts that you write.