Ask your own question, for FREE!
Computer Science 6 Online
OpenStudy (poopsiedoodle):

@wio

OpenStudy (poopsiedoodle):

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WindowsFormsApplication1 { class Tile { private int m_x; private int m_y; public int x { get { return m_x; } set { m_x = value; } } public void New(int xc, int yc) { m_x = xc; m_y = yc; } } } ```

OpenStudy (anonymous):

Try ``` public Tile(int xc, int yc) { m_x = xc; m_y = yc; } ```

OpenStudy (poopsiedoodle):

ok yeah that worked too

OpenStudy (poopsiedoodle):

is it necessary to do that instead of New though?

OpenStudy (anonymous):

Ummm, wouldn't New be a method, rather than a constructor?

OpenStudy (poopsiedoodle):

I'm used to the constructors in vb.net all being called New(), but idk yo

OpenStudy (poopsiedoodle):

Also, how do I declare a tile object outside of the tile class? Is there a using statement I need to do or something?

OpenStudy (anonymous):

Oh, well VisualBasic is weird.

OpenStudy (anonymous):

Declare a tile object outside of the tile class? Don't you just need to import it?

OpenStudy (anonymous):

What is the code that isn't working?

OpenStudy (poopsiedoodle):

`tile tile = new tile(i1, i);` trying to do `using windowsapplication1.tile` but VS doesn't like that.

OpenStudy (anonymous):

Did you make sure to capitalize correctly?

OpenStudy (poopsiedoodle):

ye. ``` Severity Code Description Project File Line Suppression State Error CS0138 A 'using namespace' directive can only be applied to namespaces; 'Tile' is a type not a namespace. Consider a 'using static' directive instead WindowsFormsApplication1 ```

OpenStudy (poopsiedoodle):

WAIT NEVERMIND I GOT IT it was capitalization in the line declaring the object capitalization is going to be the death of me

OpenStudy (anonymous):

Why would you need a tile object anyway?

OpenStudy (anonymous):

The board is made up of tile objects? What data are they keeping track of?

OpenStudy (poopsiedoodle):

ye the board is made up of tile objects, which are only in there to keep track of piece locations p much

OpenStudy (anonymous):

If you make an array of arrays to store pieces, the indices will indicate the tile positions.

OpenStudy (poopsiedoodle):

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Tile : PictureBox { private int m_x; private int m_y; public int x { get { return m_x; } set { m_x = value; } } public int y { get { return m_y; } set { m_y = value; } } public Tile(int xc, int yc) { base.@New; m_x = xc; m_y = yc; } } } ```

OpenStudy (poopsiedoodle):

The error is at base.@New;, because PictureBox's constructor isn't New, apparently. No idea what it is.

OpenStudy (anonymous):

``` public Tile(int xc, int yc) ``` Change to ``` public Tile(int xc, int yc) : base() ```

OpenStudy (anonymous):

Where do you get this `.@New` stuff?

OpenStudy (anonymous):

I don't think you can really rely much on VisualBasic for this stuff.

OpenStudy (poopsiedoodle):

I'm using a code converter to try to help understand the syntax

OpenStudy (poopsiedoodle):

converted mybase.new because that's how vb calls base constructors

OpenStudy (poopsiedoodle):

thanks again tho :*

OpenStudy (anonymous):

Not sure if you even need `: base()`, it might be default behavior

OpenStudy (poopsiedoodle):

still couldn't hurt to add it, I reckon

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!