This document contains code examples demonstrating basic input and output functions in C# using Console.WriteLine and Console.Write. It shows how to print output on single and multiple lines and examples of comparison operators like ==, !=, >, <, >=, <=. It also provides recommendations on choosing appropriate data types in C# like int, decimal, bool, string, and specialized types like byte, double, StringBuilder, DateTime, and TimeSpan.
This document contains code examples demonstrating basic input and output functions in C# using Console.WriteLine and Console.Write. It shows how to print output on single and multiple lines and examples of comparison operators like ==, !=, >, <, >=, <=. It also provides recommendations on choosing appropriate data types in C# like int, decimal, bool, string, and specialized types like byte, double, StringBuilder, DateTime, and TimeSpan.
This document contains code examples demonstrating basic input and output functions in C# using Console.WriteLine and Console.Write. It shows how to print output on single and multiple lines and examples of comparison operators like ==, !=, >, <, >=, <=. It also provides recommendations on choosing appropriate data types in C# like int, decimal, bool, string, and specialized types like byte, double, StringBuilder, DateTime, and TimeSpan.
Console.WriteLine("Hello World!"); //Print output على أسطر متعدد ولكن النتيجة سطر واحد كتابة األمر Console.Write("Congratulations!"); Console.Write(" "); Console.Write("You wrote your first lines of ode!"); /* مثال على النوعين اإلدخال 1- Console.WriteLine("This is the first line."); ناتج األمر األول This is the first line. 2- Console.Write("This is "); Console.Write("the second "); Console.Write("line."); ناتج األمر الثاني This is the second line. Code Console.WriteLine("a" == "a"); Console.WriteLine("a" == "A"); Console.WriteLine(1 == 2);
Console.WriteLine(myValue != "a"); Output False True True False Code Console.WriteLine(1 > 2); Console.WriteLine(1 < 2); Console.WriteLine(1 >= 1); Console.WriteLine(1 <= 1); Output False True True True int for most whole numbers decimal for numbers representing money bool for true or false values string for alphanumeric value Choose specialty complex types for special situations. Don't reinvent data types if they already exist for a given purpose. byte for working with encoded data that comes from other computer systems or using different character sets. double for working with geometric or scientific purposes. double is used frequently when building games involving motion. System.StringBuilder to build a single string from many literals or other variables. We'll cover this in more detail in the Modify content of strings using built-in string data type methods in C# module. System.DateTime for a specific date and time value. System.TimeSpan for a span of years /months /days /hours /minutes /seconds/milliseconds.