When we write text "as is", as in the previous example above, we enclose it in quotes. But in most occasions we will not want to write predefined texts, but something which must be calculated.
A very simple example is a mathematical operation. We will not use quotation marks for it, so our C# compiler will try to parse the contents of the expression and guess what we mean. For example, to sum 3 and 4 we would do as follows:
public class Example01sum
{
public static void Main()
{
System.Console.WriteLine(3+4);
}
}
Suggested exercise: Write a C# program to display the sum of 118 and 56.
No comments:
Post a Comment