本帖最后由 葛杨杨 于 2013-5-23 14:49 编辑
帮忙纠正一下,下面是错误提示和代码:
错误 1 无法将类型“int”隐式转换为“string” D:\C语言代码\C语言从入门到精通\值类型与引用类型的区别\Program.cs 26 60 值类型与引用类型的区别
错误 2 无法将类型“int”隐式转换为“string” D:\C语言代码\C语言从入门到精通\值类型与引用类型的区别\Program.cs 27 57 值类型与引用类型的区别
错误 3 无法将类型“string”隐式转换为“int” D:\C语言代码\C语言从入门到精通\值类型与引用类型的区别\Program.cs 28 21 值类型与引用类型的区别
错误 4 无法将类型“int”隐式转换为“string” D:\C语言代码\C语言从入门到精通\值类型与引用类型的区别\Program.cs 29 25 值类型与引用类型的区别- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace 值类型与引用类型的区别
- {
- class Program
- {
- static void Main(string[] args)
- {
- ReferenceAndValue.Demostration();
- Console.ReadLine();
- }
- }
- public class stamp
- {
- public string Name{ get; set; }
- public string Age{ get; set;}
- }
- public static class ReferenceAndValue
- {
- public static void Demostration()
- {
- stamp Stamp_1 = new stamp{Name="Premiere", Age=25};
- stamp Stamp_2 = new stamp{Name="Again", Age=47};
- int age=Stamp_1.Age;
- Stamp_1.Age=22;
- stamp gurn =Stamp_2;
- Stamp_2.Name="Again Amend";
- Console.WriteLine("Stamp_1's age:{0}", Stamp_1.Age);
- Console.WriteLine("age' value:{0}",age);
- Console.WriteLine("Stamp_2's name: {0}",Stamp_2.Name);
- Console.WriteLine("gurn's name:{0}",gurn.Name);
- }
- }
- }
复制代码 |