Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency structure occurs CS0188 error in TargetFramework net6.0 or greater #3844

Open
s2quake opened this issue Jun 21, 2024 · 0 comments
Open
Assignees

Comments

@s2quake
Copy link
Contributor

s2quake commented Jun 21, 2024

The detailed message of the CS0188 error is shown below

error CS0188: The 'this' object cannot be used before all of its fields have been assigned.

In the Currency struct constructor, it uses a local method called GetHash to set a value in a field called Hash. This violates the rule described above.
I think the problem would be solved if the field Hash didn't need to be defined, but rather calculated and used as needed.

        public Currency(IValue serialized)
        {
            ...
            Hash = GetHash(); // CS0188 error
        }

@s2quake s2quake self-assigned this Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant