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

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 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题