rmmarsh
asked on
Struct in a method...
Why can't I have this code? It's saying the struct is an "unexpected symbol". I have the same exact struct in another class. (this is part of a partial class).
public void SaveLevelingData() {
List<ReductionData> sArray = new List<ReductionData>();
struct ReductionData {
string reductionID;
string reductionFS;
string computedReduction;
}
In .NET, you can't define structs within methods. You can either define them within a class or within a namespace, just not within a method.
ASKER
Tried that, but it says "a namespace can only contain types and namespace declarations".
What now? :D
What now? :D
List<ReductionData> sArray = new List<ReductionData>();
struct ReductionData {
string reductionID;
string reductionFS;
string computedReduction;
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Try this:
Gary Davis
public void SaveLevelingData()
{
List<ReductionData> sArray = new List<ReductionData>();
}
public class ReductionData {
string reductionID;
string reductionFS;
string computedReduction;
}
Gary Davis
ASKER
Thanks...