Jump to content
  • Advertisement
Sign in to follow this  
brasslips2

[C#] - Noob constructor question

This topic is 3084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm pretty new to C# and have an error that I don't understand...

Here is my error: error CS1729: 'LevelEditor.Graphics.GraphicsEngine' does not contain a constructor that takes '1' arguments

The weird part is that I DO have a constructor that takes 1 argument defined in my graphics engine class... Any help on this would be great! Thanks!

In main.cs:


static void Main()
{
MainClass form = new MainClass(); // Create the form

//Initialize the Engines
GraphicsEngine m_graphics = new GraphicsEngine(ref form);
...

}



In Graphics.cs

namespace LevelEditor.Graphics
{
public class GraphicsEngine
{
private Device DX_Device = null;

GraphicsEngine(ref MainClass form)
{
if (InitializeDirect3D(ref form) == false)
{
MessageBox.Show("Could not initialize Direct3D.", "Error");
return;
}
}
}
}

Share this post


Link to post
Share on other sites
Advertisement
You need to make the constructor public:

public GraphicsEngine(ref MainClass form)

Share this post


Link to post
Share on other sites
If I do that then I get this error:

error CS0051: Inconsistent accessibility: parameter type 'ref LevelEditor.MainClass' is less accessible than method 'LevelEditor.Graphics.GraphicsEngine.GraphicsEngine(ref LevelEditor.MainClass)'

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!