0

This question already has an answer here:

Below is a snippet of code that I have extracted for illustrative purpose only.

I have an enum declared in Solidity and returns in a function.

enum State { start, end }
function Test() public view returns(uint, State) ....

In my Nethereum CSharp DTO, may I know how can I model the enum? And how do I know the value of start and end? Are they default to 0 and 1?

[Parameter("enum", 2)]
public int State { get; set; }

Note: This is not duplicate of the JavaScript question, and it is about the conversion from Solidity to Nethereum (in CSharp).

marked as duplicate by flygoing, Achala Dissanayake, mirg, Asone, Richard Horrocks Mar 27 '18 at 18:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It looks like Solidity enums work the same as other enums, ie integer types starting at 0. Have you tried just duplicating the definition with start = 0 and end = 1? (It's not ideal, sure.) – Jamie Hale Mar 26 '18 at 15:33
  • I have to explicitly cast it to uint otherwise the DTO can't work. Not sure why. – s k Mar 26 '18 at 22:19

Browse other questions tagged or ask your own question.