मैं सी # में enums साथ परेशानी हो रही हूँमेरे सी # एनम्स क्यों काम नहीं कर रहे हैं?
मैं यहाँ एक enum है:
using Project.Shared;
namespace Project.Shared.FooNamespace
{
public class Foo
{
public int CostType { get; set; }
public Foo()
{
CostType = (int)CostType.Dollars; // <--- error syntax highlighting on 'Dollars'
}
}
}
इस में जो परिणाम:
namespace Project.Shared
{
public enum CostType
{
Dollars,
Percent
}
}
मैं एक वस्तु है कि enum यहाँ उपयोग करने के लिए कोशिश कर रहा है है एक त्रुटि:
'int' does not contain a definition for 'Dollars' and no extension method 'Dollars' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
मुझे समझ में नहीं आता कि मैं एम का उपयोग क्यों नहीं कर सकता वाई एनम वहाँ। क्या कोई मुझे यह समझाने में मदद कर सकता है?
यह एक संकेत हो सकता है कि आपको संपत्ति के लिए enum के लिए समान नाम का उपयोग नहीं करना चाहिए। –
यदि आप enum प्राप्त कर चुके हैं और आप enum मान चाहते हैं तो आप मूल्य को int के रूप में क्यों स्टोर करना चाहते हैं? – WestDiscGolf
क्योंकि EntityFramework अभी तक एम्स को मैपिंग का समर्थन नहीं करता है। – quakkels