如何将ENUM值从视图转换为字符串到控制器 [英] How to convert the ENUM value to String from view to a controller

查看:126
本文介绍了如何将ENUM值从视图转换为字符串到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我已经知道如何获取字符串,int,decimal,现在我正在努力在这个枚举的这一部分。如何将我的枚举转换成字符串

  ** Enum statecode = apsp.Customer.BillingAddress.StateCode.Value; ** 
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
** StateCode = statecode **,
ZipCode = zipcode
}
},

所以我想插入这个的值..



Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;

  

到此枚举

  StateCode = statecode,


解决方案

  Enum statecode = apsp.Customer.BillingAddress.StateCode; 
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
StateCode =(StateCode)statecode,
ZipCode = zipcode
}
},


So I already know how to get the string,int,decimal and now I'm struggling in this part of enum. How can I convert my enum into a string

**Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;**
Customer = new Customer()
       {
         FirstName = fn,
         LastName = ln,
         BillingAddress = new Address
             {
              StreetAddress1 = street1,
              StreetAddress2 = street2,
              City = city,
              **StateCode = statecode**,
              ZipCode = zipcode
              }
        },

so I want to insert the value of this..

Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;

to this enum

StateCode = statecode,

解决方案

Enum statecode = apsp.Customer.BillingAddress.StateCode;
Customer = new Customer()
   {
     FirstName = fn,
     LastName = ln,
     BillingAddress = new Address
         {
          StreetAddress1 = street1,
          StreetAddress2 = street2,
          City = city,
          StateCode = (StateCode)statecode,
          ZipCode = zipcode
          }
    },

这篇关于如何将ENUM值从视图转换为字符串到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆