0% found this document useful (0 votes)
85 views

Using System

The document contains code that demonstrates initializing and assigning values to variables in C#. It initializes an integer variable bien1 with the value 3, then assigns it the value 10. It outputs the initial and assigned values of the variable to demonstrate variable initialization and assignment.

Uploaded by

Phạm Trâm
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Using System

The document contains code that demonstrates initializing and assigning values to variables in C#. It initializes an integer variable bien1 with the value 3, then assigns it the value 10. It outputs the initial and assigned values of the variable to demonstrate variable initialization and assignment.

Uploaded by

Phạm Trâm
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System; using System.Collections.Generic; using System.

Text; namespace Debug2a { class Program { static void Main() { string name, bossName; bool areNamesTheSame; Console.WriteLine("Enter your name"); name=Console.ReadLine(); Console.WriteLine("Hello {0}! Enter the name of your boss", name); bossName=Console.ReadLine(); areNamesTheSame = String.Equals(name, bossName); Console.WriteLine("It is {0} that you are your own boss", areNamesTheSame); } } }

using System; using System.Collections.Generic; using System.Text; namespace SuDungBien { class MinhHoa { static void Main() { int bien1 = 3; // khai Console.WriteLine("Sau bien1 = 10; // gn gi Console.WriteLine("Sau Console.ReadLine(); } } }

bo khi tr khi

v khi to gi tr cho mt bin khoi tao: bien1 ={0}", bien1); cho bin gan: bien1 ={0}", bien1);

using System; using System.Collections.Generic;

using System.Text; namespace Debug2c { class Program { public static void Main() { const double WITHHOLDING_RATE = .15; string hoursAsString, rateAsString; double hours, rate; double gross, net; Console.Write("Enter the number of hours you worked this week") ; hoursAsString = Console.ReadLine(); Console.Write("Enter your hourly rate "); rateAsString = Console.ReadLine(); hours = Convert.ToDouble(hoursAsString); rate = Convert.ToDouble(rateAsString); gross = hours + rate; net = gross - gross * WITHHOLDING_RATE; Console.WriteLine("You worked {0} hours at {1} per hour", hours, rate.ToString("C")); Console.WriteLine("Gross pay is {0}", gross.ToString("C")); Console.WriteLine("Net pay is {0}", gross.ToString("C")); } } }

You might also like