首页 > 解决方案 > 这个箭头符号有什么问题?

问题描述

我在 c# 中有以下文件,我正在使用 VS 2013,但我卡在“=>”符号上,VS 总是要求输入“;” 在以下文件中的“=>”符号之后:

namespace GlobomanticsElectricCompany.BillProcessor.Models
{
    public class ContactInfo
    {
        public string Line1 { get; set; }
        public string Line2 { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string Zip { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
        public string CityStateZip => $"{City}, {State} {Zip}";
    }
}

我应该怎么做才能让 VS 识别那个“=>”符号?

标签: c#

解决方案


我最近遇到了这个问题;我不相信 => 语法在该版本的 Visual Studio 中有效。尝试像这样定义它:

    public string CityStateZip
    {
        get
        {
            return City + " , " + State + " " + Zip;
        }
    }

推荐阅读