Echo.Success 2021-09-13 16:10 采纳率: 50%
浏览 35
已结题

VS中,C#调试代码,找不到问题点


using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            ReferenceAndValue.Demonstrsition();
            Console.ReadLine();
        }
    }

    public class stamp
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
    
    public static class ReferenceAndValue
    {
        public static void Demonstrsition()
        {
            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 Stamp_3 = Stamp_2;
            Stamp_2.Name = "Again Amend";
            Console.WriteLine("Stamp_1's age:{()}", Stamp_1.Age);
            Console.WriteLine("age's value:{()}", age);
            Console.WriteLine("Stamp_2's name:{()}", Stamp_2.Name);
            Console.WriteLine("Stamp_3's name:{()}", Stamp_3.Name);
        }
    }
}

报错:
引发的异常:“System.FormatException”(位于 System.Private.CoreLib.dll 中)
“System.FormatException”类型的未经处理的异常在 System.Private.CoreLib.dll 中发生
Input string was not in a correct format.引发的异常:“System.FormatException”(位于 System.Private.CoreLib.dll 中)
“System.FormatException”类型的未经处理的异常在 System.Private.CoreLib.dll 中发生
Input string was not in a correct format.

  • 写回答

1条回答 默认 最新

  • 大李杜 2021-09-13 16:27
    关注
    
    
    using System;
    
    namespace ConsoleApp1
    {
        class Program
        {
            static void Main(string[] args)
            {
                ReferenceAndValue.Demonstrsition();
                Console.ReadLine();
            }
        }
    
        public class stamp
        {
            public string Name { get; set; }
            public int Age { get; set; }
        }
    
        public static class ReferenceAndValue
        {
            public static void Demonstrsition()
            {
                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 Stamp_3 = Stamp_2;
                Stamp_2.Name = "Again Amend";
                Console.WriteLine($"Stamp_1's age:{Stamp_1.Age}");
                Console.WriteLine($"age's value:{age}");
                Console.WriteLine($"Stamp_2's name:{Stamp_2.Name}");
                Console.WriteLine($"Stamp_3's name:{Stamp_3.Name}");
            }
        }
    }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月22日
  • 已采纳回答 9月14日
  • 创建了问题 9月13日

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果