命名空间"Enum"中不存在类型或命名空间名称"Parse"



我有系统在我的命名空间,我错过了什么?我是c#的新手,正在学习关于Udemy的课程和一本名为c# 8.0和。net Core 3.0的书-人们推荐的任何其他材料都会非常有用。

问题是由Enum引起的。解析

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Enum
{
public enum ShippingMethod
{
RegularMail = 1,
Registered = 2,
Express = 3
}
class Program
{
static void Main(string[] args)
{
var method = ShippingMethod.Express;
Console.WriteLine((int)method);
var methodId = 3;
Console.WriteLine((ShippingMethod)methodId);
Console.WriteLine(method.ToString());
//Here we take a string and convert it a enum
var methodName = "Express";
//We will have to "parse" the string to a different type
var shippingMethod = (ShippingMethod)Enum.Parse(typeof(ShippingMethod), methodName);
}
}
}

我必须将其更改为System. enum.parse - odd,因为我使用了System;

namespace Enum_1
{
public enum ShippingMethod
{
RegularMail = 1,
Registered = 2,
Express = 3
}

更改命名空间Enum,类似于Enum_1

您必须检查您的命名空间不是{{您的解决方案名称}}。Enum

最新更新