| |
| |
| |
|
Comments:
<0> Anybody home that might help me with a quick C# question? <0> 22 Connected, 22 Asleep? :( <1> conspiring to conquer the world <0> Oh good <0> Might you be able to help me? <0> I have an object that I've instanced within Main() <0> Main() calls out to another function called Create(), which in turns calls out a third function called Define() <0> Inside of Define, I am trying to do OBJECT.Function = Blah and it tells me that OBJECT could not be found <0> No typos, and all constructors and acessors / mutators are public <1> um <1> and OBJECT is what? <0> A defined cl*** within another namespace
<0> I've got the namespace attached with using at the top <1> hm <1> its not part of another ***embly that needs to be added as a reference? <1> i guess the use clause would fail then <0> I don't think so.. But I've never used ***emblys and references like that.. The namespace in which OBJECT is defined is in another .cs file <0> If I try to do OBJECT.Function = Blah within Main() it works just fine <0> But in this static void subroutine, it tells me OBJECT cannot be found <1> well obviously from a static method you would only be able to access static vars and methods.. is OBJECT static? <1> even in wherever it is <1> or is it a variable you p*** on to that method? <0> OBJECT is only defined as "cl*** OBJECT" <0> i.e. cl*** OBJECT { constructor(){} } <1> oh right. it's a cl***. <1> im tired :p <0> No worries, so am I =) <0> public constructor(){} as well, by the way <1> but um.. <1> this thing you're trying to ***ign something to, is it a property ? <0> Yes <1> a static one? <0> public string FName { get {} set{} } <0> So OBJECT.FName = "Blah"; should work <0> I thought <0> And it does, if I do the OBJECT.FName = "Blah"; from inside of Main() just not out in this external method <1> uh no you'd have to instantiate the cl*** first <0> It is, within Main() <0> Player PLAYER = new Player(); To be exact <1> but then you'd have to do (the instance of OBJECT).FName = whatever <0> So PLAYER.FName = "Blah"; should work, it just doesn't see PLAYER outside of Main() and that's the bugger part that I'm confused on <1> right so PLAYER is an instance of Player <0> Yes <1> right then. <1> [NoV]Pops> OBJECT is only defined as "cl*** OBJECT" <1> 00:37 < [NoV]Pops> i.e. cl*** OBJECT { constructor(){} } <1> .. confused me :P <1> there you said it was the cl*** itself <0> Sorry, was trying to use general terms rather then the Specific ones.. Looks like I added more confusion the needed <1> usually that happens yes :P <0> So technically, I have cl*** Player { Player(){} } <0> With the constructor being Public <1> ok well as long as you have the correct use clauses and p*** on the instance it should work <1> i cant see any other reason <0> Is use a keyword I'm not aware of? <0> I thought that once an Object was instanced it sort of existed for all to see and manipulate depending on the acess levels of it's various accessors and mutators? <1> it's not global, of course <1> if that's what you mean <1> you'd have to p*** it on through to the methods that need it <1> OR; create a static cl*** that you can stuff it into :P <1> i guess thats the only way of doing globals in c# <1> or can you have static vars hm. i dont remember :P <0> So static cl*** Player ?
<1> no i mean like <0> Doesn't that not allow me to Player.FName = "Whatever";? <1> static Player PLAYER = new Player(); <1> but im not sure if that's allowed. can't remember atm <0> Ah.. Let me give that a go <1> but that's really bad design if you ask me <1> you should p*** the variables you need on through the parameters to your functions <0> static Player PLAYER didn't work, errored out <1> unless there's something i'm not following in how you're doing stuff <0> How do I p*** my instance through to my functions? <1> well, like you'd do with any variables <1> public returntype methodname(variabletype variablename) .. etc <0> In my function signatures I'd need a definition to catch it with.. i.e. like int b; Would I be able to do object P;? <0> I guess that would make sense.. Let me see if that works or not <1> you can do Create(Player P, int 4, object o) etc for all i care <1> er 4 not allowed but some naem heh <1> then just p*** on the P reference furhter <1> or PLAYER if you want <1> i find uppercase is messy <1> use camel notation .p <1> pascal notation for cl***es and properties <0> Ya, I do with normal variable names <1> camel notation for variables/instqnaces <1> i havent quite agreed with myself on _varname vs m_varName yet :P <1> for private data <0> P.FName 'object' does not contain a definition for FName <1> yes you're treating it as an boject <1> object <1> you have object P ? <1> you'd either have to use Player P or (Player)P.FName <0> Right, just did the Player P (Caught my own mistake before I came back to this wonidow ;) ) <0> Now it's giving me an Inconsistant Acessability. Says N.Player is less acessable then the method <0> So it's a matter of figuring out Public and such correctly I think... <0> You've definately got me on the right track... Let me see what the Dynamic help has to offer on this <1> hm <0> Ah ha! <0> that got it <0> cl*** Player is now defined at public cl*** Player <0> And that got me past those <1> ah yes <0> I thought cl*** was public by default? <1> easy to forget <1> apparently not :) <0> Heh <0> Thanks for the nudge in the right direction <0> Much appriciated <1> keeping track of default visibility when switching between c++, java, c# and delphi is a mess <1> and how visiblity works in general hehe <1> e.g. friend (c++), same unit (delphi), private internal (c#), and whatever java has :P <1> anyhow. good luck .p <0> Thanks again.. <2> whow ants to help with my xml problems? :) <3> how can i write hello world <1> hello world <3> yes <1> i just did <1> System.Console.Write..something("Hello, World"); <3> okay i'll try <3> thx <3> cool works
Return to
#csharp or Go to some related
logs:
#stocks robocopy long pathname
#computers #ubuntu blk_jack #microsoft #gentoo #unixhelp #unixhelp #italy
|
|