Q:

How to get a contract's balance in Solidity?

How do I get the balance of a contract with solidity?
I know geth has web3.eth.getBalance(), but that's to get the contract balance after it has been deployed.
Is there a standard way of doing this, or do I have to have a separate var that uint256 that keeps track of the total balance?

A:

You can do this by calling address.balance. To get the contract's balance, just do this.balance. Read the docs.
Update: As of Solidity ^0.4.24, you need to do:
address(this).balance

(Copied from answer by Paul Berg)

A:

Small update from my side:

You want to use the following, address(this).balance;

A:

As of Solidity ^0.4.24, you need to do:
address(this).balance

Find an example here.

