Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.45 KB

File metadata and controls

34 lines (26 loc) · 1.45 KB
title Addendum: Variable Limitations for NEO Contracts
actions
checkAnswer
hints
material
editor
language startingCode answer
c#

Because NEO Virtual Machine is more compact than .Net, NEO's C# compiler only supports a limited number of variables from C#. Considering the large scope of features in C#, it is helpful to take a white-list approach, and look at the basic types that are fully supported by the compiler:

  • ByteArray
  • Integer
  • Boolean
  • Array
  • Struct
  • Map
  • Interface

Some other commonly used types are implemented through one of the above types, for example:

  • All integral types (int, uint, ulong, ...) are implemented as BigInteger from System.Numerics, and are fully supported
  • string is implemented in NEO VM as its UTF8 ByteArray, which means it does not support the string handlers native to .Net
  • char is implemented as integer

See this page for a detailed account on supported types and limitations.

Built-in Types

The NEO library also has a few built-in types to address the lack of a some C# types.

  • BigDecimal is a custom struct that can be used to define a decimal number. It can be used in place of float point numbers.

  • Map is a custom class used for key-value dictionaries.