6 Replies - 16127 Views - Last Post: 01 June 2010 - 11:02 AM Rate Topic: -----

#1 gordon13   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-October 07

Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 05:50 AM

I need to access a variable in a class that is in a different namespace to the class that needs that variable. Is it possible to access that variable? Or maybe theres a way around to get the data?
Is This A Good Question/Topic? 0
  • +

Replies To: Is it possible to access a variable from a different namespace?

#2 FlashM   User is offline

  • D.I.C Lover
  • member icon

Reputation: 383
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 05:52 AM

Sure it's possible.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 06:10 AM

If they are in completely separate namespaces, then you have to add a Reference to the other namespace.
Was This Post Helpful? 0
  • +
  • -

#4 gordon13   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-October 07

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 06:58 AM

namespace GameEntities
{

namespace Game
{

those are the two namespaces so I guess they are completely seperate. I tried adding a reference to Game in GameEntities, but I get an error saying:
"a reference to 'game' could not be added. Adding this project reference would cause a circular dependency".
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 09:05 AM

Game is inside the namespace GameEntites, or put another way GamesEntities contains the namespace Game.

You to expand the variable you trying to access to include the namespace it is in.
Was This Post Helpful? 0
  • +
  • -

#6 EvLSnoopY   User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • Posts: 93
  • Joined: 24-November 09

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 09:18 AM

You shouldn't be getting that error if you have 2 different .cs files and 2 different namespaces.
Was This Post Helpful? 0
  • +
  • -

#7 gordon13   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-October 07

Re: Is it possible to access a variable from a different namespace?

Posted 01 June 2010 - 11:02 AM

Sorry I think I confused the issue in my previous post. The GameEntities and Game namespaces above are in seperate cs files. GameEntities, doesnt contain Game. Each class is also in a separate project inside the solution.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1