user6770: So, after understanding how to create and send raw transactions on the basis of 'How to send from many bitcoin addresses to one bitcoin address?', in practice I still struggle with transaction fees. For example, I do the following in order to calculate the size of an hex-encoded transaction:
hex_raw_transaction = createrawtransaction(...)
hex_raw_transaction = signrawtransaction(hex_raw_transaction)
byte[] size = HexStringToByteArray(hex_raw_transaction)
int transaction_size = size.Length

Is that a correct way to determinate the transaction size? (Regarding to https://en.bitcoin.it/wiki/Transaction_fees)? 
Is it correct that the transaction fee is set by the unassigned amount in the outputs?
For example, if I have 1 BTC in one address and send the 0.65 BTC to a second address and 0.3495 BTC as change to the first
//The fee will be: 
fee = 1 - (0.65 + 0.3495)  //= 0.0005 btc

is it correct that the fee will be 0.0005 BTC? 

user6288: Here is a great answer on how to calculate the transaction size before sending. (Make sure to read the final edit.)
As for the fee, you've got it right: whatever amount from the inputs is NOT sent to other addresses, becomes the transaction fee for the miners.

6770: <p>So, after understanding how to create and send raw transactions on the basis of <a href="https://bitcoin.stackexchange.com/questions/13332/how-to-send-from-many-bitcoin-addresses-to-one-bitcoin-address">'How to send from many bitcoin addresses to one bitcoin address?'</a>, in practice I still struggle with transaction fees. For example, I do the following in order to calculate the size of an hex-encoded transaction:</p>

<pre><code>hex_raw_transaction = createrawtransaction(...)
hex_raw_transaction = signrawtransaction(hex_raw_transaction)
byte[] size = HexStringToByteArray(hex_raw_transaction)
int transaction_size = size.Length
</code></pre>

<p>Is that a correct way to determinate the transaction size? (Regarding to <a href="https://en.bitcoin.it/wiki/Transaction_fees" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Transaction_fees</a>)? </p>

<p>Is it correct that the transaction fee is set by the unassigned amount in the outputs?</p>

<p>For example, if I have 1 BTC in one address and send the 0.65 BTC to a second address and 0.3495 BTC as change to the first</p>

<pre><code>//The fee will be: 
fee = 1 - (0.65 + 0.3495)  //= 0.0005 btc
</code></pre>

<p>is it correct that the fee will be 0.0005 BTC? </p>
 6288: <p><a href="https://bitcoin.stackexchange.com/a/3011/6288">Here</a> is a great answer on how to calculate the transaction size before sending. (Make sure to read the final edit.)</p>

<p>As for the fee, you've got it right: whatever amount from the inputs is NOT sent to other addresses, becomes the transaction fee for the miners.</p>
