|
-
October 8th, 2009, 02:56 AM
#1
non-static member of outer type
Hey, i get the following error when i try to compile my project:
Cannot access a non-static member of outer type 'Project.Shader' via nested type 'Project.Shader.RenderSurfaceSet'.
What i'm doing is the following.
I have a class called worldView.cs, in that class i create the Shader class like so:
[Inside worldView.cs]
Code:
Shader shader = new Shader(this);
As you can see a pass an instance of the worldView class to the shader class. The shader class uses some variabled declared in the worldView class without a problem.
But here comes the issue:
In the Shader.cs class i also have a struct defined inside the class, like so:
Code:
public class Shader
{
public View.WorldView world;
RenderSurfaceSet[] downscaledSets;
public Shader(View.WorldView world)
{
this.world = world;
Initialize();
}
//some functions inside the class
//the struct
struct RenderSurfaceSet
{
//some variables here
public RenderSurfaceSet(int downscalingFactor, int sourceTexture)
{
//code in constrcutor
}
//and some other functions inside this struct
}
}
Now what i'm trying to do is also use the worldView instance inside this struct. The worldView object seems to be accessible from within that struct, but when i try to compile it it generates that error.
Anyone any idea how to solve that??
Last edited by vivendi; October 8th, 2009 at 03:10 AM.
-
October 8th, 2009, 04:17 AM
#2
Re: non-static member of outer type
can you point out the line in the code inside the structure where this error is pointing?
Is it inside the function with the structure or in assigment or just reading the value inside the structure?
-
October 8th, 2009, 11:41 AM
#3
Re: non-static member of outer type
Well, you have omitted the code which is actually causing the error, but your struct will not be able to access non-static data defined in your Shader class. This would be true for any class or struct, regardless of where/how it was defined. You are probably trying to access instance variables with no instance of "Shader" to refer to.
Last edited by BigEd781; October 9th, 2009 at 01:16 AM.
-
October 8th, 2009, 11:46 PM
#4
Re: non-static member of outer type
Code:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct ParserFunctionInfoTry
{
public class Parameters
{
#region Parent Class
public CTElement parentClass = null;
#endregion
#region Name
private String _name;
[Browsable(true)]
[Category("Data")]
public String Name
{
get { return _name; }
set { _name = value; }
}
}
Parameters _param;
public List<Parameters> _paramLst;
[Browsable(true)]
[Category("Data")]
public List<Parameters> parameterLst
{
get
{
return _paramLst;
}
set { _paramLst = value; }
}
}
here I have a case where a class is defined inside a structure and accessible with in that structure....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|