View Single Post
  #4 (permalink)  
Old January 3rd, 2010, 01:00 AM
jawadh_khan786 jawadh_khan786 is offline
Registered User
 
Join Date: Dec 2009
Location: Hyderabad, AP, India
Posts: 4
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via Yahoo to jawadh_khan786
Lightbulb Pay attention here

Hello C# learners and programmers

Depending on your query here... please pay attention on the page no. 47, and in the table provide observe carefully the second row on -(subtraction operator)

Operator is:
Code:
 -
category: Binary
Eg Expression:
Code:
 var1 = var2 - var3
Result:
var1 is assigned the value that is the value of var3 subtracted from the value of var2.

Example:

if we want to subtract 5(firstNumber) from 10(secondNumber) then the code below is invalid

Code:
Console.WriteLine("The result of subtracting {0} from {1} is: {2}.", firstNumber, secondNumber, firstNumber - secondNumber);
Execution of above code gives annoying result

Code:
 The result of subtracting 5 from 10 is: -5
Hence the code below is perfectly valid

Code:
 Console.WriteLine("The result of subtracting {0} from {1} is: {2}.", firstNumber, secondNumber, secondNumber - firstNumber);

Cheers!!!
Regards C# expert
SparkSoft®

Last edited by jawadh_khan786; January 3rd, 2010 at 01:03 AM..