Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# Unary Operators

using System;
 
namespace Operator
{
	class UnaryOperator
	{
		public static void Main(string[] args)
		{
			int number = 10, result;
			bool flag = true;

			result = +number;
			Console.WriteLine("+number = " + result);

			result = -number;
			Console.WriteLine("-number = " + result);

			result = ++number;
			Console.WriteLine("++number = " + result);

			result = --number;
			Console.WriteLine("--number = " + result);

			Console.WriteLine("!flag = " + (!flag));
		}
	}
}
Source by www.codecademy.com #
 
PREVIOUS NEXT
Tagged: #Unary #Operators
ADD COMMENT
Topic
Name
4+9 =