- Home /
C# Enums get and set accessor expected
Does anybody know why I am getting the "get and set accessor expected" error on InAndOut when creating a enum like so....
using System;
public static struct TargetFinding
{
public Enum View
{
InAndOut,
In,
Out
}
}
Answer by Joshua · Jul 08, 2011 at 01:06 PM
I think you need an endline when closing your enum. Add a ; after the first } in your script. I also believe there's no need to declare it as public. But I'm no hero when it comes to C#, so I may be way off.
Ye I'm not sure if I need to either. I'll try it without the public and see what happens. Not sure if the semicolon is needed either but I'll add it because semicolons are used in the msdn docs. Thanks
Just tested without public and just for other peoples reference it does need to be public.
It need to be public when you wnat to use it outside of the struct. The default visibillity in C# is private in Unityscript it's public.
Answer by Blankzz · Jul 08, 2011 at 01:07 PM
Sorry I was using Enum instead of enum.........
Well, that's what i would have suggested ;) System.Enum is a class. Btw. do you need it in a struct? You can declare enums even outside of a class / struct. If you need some kind of namespace it's ok
I don't need them in a struct but its a bit clearer what they are for this way.
Your answer

Follow this Question
Related Questions
Enum not existing in context, but it is right there! 2 Answers
C# Show public members from a second class in Inspector 1 Answer
Rotate an object a set angle over time? (C#) 1 Answer
what is an enum ? 2 Answers
Enum option into a game menu gui 1 Answer