c++ - Implementing own data types in C# without enum? -


the main difference between built-in data types , user defined data types that: built-in data types can accept literal values(values inserted code directly,this process know hard-codding).

so possible create custom data type same boolean accepts 3 values: yes/no/maybe without using enums.

such following code:

mycustomboolean = maybe; 

i asked above question because want understand built-in data types in c# instructed in core language(such c++ int,char...) or no?

---update---

for second question,let me ask question make 2nd question more clear:

i know example string alias of system.string pure string in c# works without system.string?

there no ways you've requested. can create constant fields in c# can accomplish result (named values) integral types or strings - in other words, things can use compile-time constants. can particularly useful otherwise magic values.

public const string maybe = "maybe"; public const int maybe = 0; 

one way around this, though not usable true constant, initialize static readonly fields or properties. example

public static readonly mycustomboolean maybe { { return new mycustomboolean(); } } public static mycustomboolean maybe = new mycustomboolean(); 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -