Friday, 15 May 2015

operators - Precedence of cast in c# -



operators - Precedence of cast in c# -

this question has reply here:

cast operation precedence in c# 2 answers

what precedence of cast in c#? illustration in next code, z less or equal two?

double x = 4.5; double y = 2.1; double z = (int) x / y;

the cast beats binary operators binding. hence (int)x / y means ((int)x)/y.

on other hand, should prefer readable code clever code, since don't know should write next instead:

((int)x) / y

note brackets free, , create code more readable.

c# operators

No comments:

Post a Comment