2017-03-14 15 views
2

文字列、int、10進数を取得する方法はすでにわかっていますが、今はenumのこの部分で苦労しています。 .ToString()はdoesnの場合はどのように私は私の列挙型は、この列挙ENUM値をビューからコントローラに変換する方法

StateCode = statecode, 
+1

statecode.ToString()これを試してください。 –

+0

私はすでにそれを試しました – Woshooo

+0

オブジェクトの 'Address'内の' Statecode'プロパティはEnumですか? – NotTelling

答えて

1
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 
      } 
    }, 
-2

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

..ので、私はこれの値を挿入したい

**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 
       } 
     }, 

文字列に変換することができますあなたは、あなた自身のパーサを書くこともできます:

string EnumToString(Enum myEnum) 
{ 
    switch (myEnum) 
    { 
     case MyEnumSpecialType : 
     return "MyEnumSpecialType"; 
     //.... 
     default : 
     return ""; 
    } 
} 
+0

すべての行は赤です – Woshooo

関連する問題