کد ها و عکس ها از این سایت برداشته شده ، گذاشتمش اینجا که بعدا کامل کنم.
using System; namespace FunctionsDemo { class Program { static void Main(string[] args) { int a = 15; int b = a; b = 30; Console.WriteLine(a); Console.ReadKey(); } } }
using System; namespace FunctionsDemo { class Program { static void Main(string[] args) { Employee Emp1 = new Employee(); Emp1.EmployeeID = 1001; Emp1.Name = 'James' Employee Emp2 = Emp1; Emp1.Name = 'Smith' Console.WriteLine($'Emp1 Name = {Emp1.Name}'); Console.WriteLine($'Emp2 Name = {Emp2.Name}'); Console.ReadKey(); } } public class Employee { public int EmployeeID; public string Name; } }
using System; namespace FunctionsDemo { class Program { static void Main(string[] args) { Employee Emp1 = new Employee(); Emp1.EmployeeID = 1001; Emp1.Name = 'James' UpdateName(Emp1); Console.WriteLine($'Emp1 Name = {Emp1.Name}'); Console.ReadKey(); } public static void UpdateName(Employee Emp2) { Emp2.Name = "Smith" Console.WriteLine($'Emp2 Name = {Emp2.Name}'); } } public class Employee { public int EmployeeID; public string Name; } }
using System; namespace FunctionsDemo { class Program { static void Main(string[] args) { Employee Emp1 = new Employee(); Emp1.EmployeeID = 1001; Emp1.Name = 'James' UpdateName(Emp1); Console.WriteLine($'Emp1 Name = {Emp1.Name}'); Console.ReadKey(); } public static void UpdateName(Employee Emp2) { Emp2 = null; } } public class Employee { public int EmployeeID; public string Name; } }
using System; namespace FunctionsDemo { class Program { static void Main(string[] args) { Employee Emp1 = new Employee(); Emp1.EmployeeID = 1001; Emp1.Name = 'James' UpdateName(ref Emp1); Console.WriteLine($'Emp1 Name = {Emp1.Name}'); Console.ReadKey(); } public static void UpdateName(ref Employee Emp2) { Emp2 = null;} } public class Employee { public int EmployeeID; public string Name; } }