Click here to Skip to main content
16,020,447 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Here is another basic question I have.

in C#, if I'm given this

james.Frontleft.paws.cells.insideCell

how on earth am I suppose to know if this is either

1. a namespace with the last word being a class

2. an object within an object within an object within an object etc.

3. a namespace with the last word being a property
Posted
Comments
Dalek Dave 10-Jan-11 14:40pm    
"why can't Microsoft make it easy and make a distinction between each one"
Many people for many years have wondered about the machinations of the combine gestaltic mind of Microsoft!

Could depend on the namespace conventions within an organisation!
But they are all objects.

Seeing it outside of context makes it virtually impossible to say exactly what is what.

Given what it looks like I would suggest the last word was a property, but as I say, seeing it naked like that makes it impossible to be sure.
 
Share this answer
 
Comments
nic77m 10-Jan-11 14:43pm    
actually, I made the code up...here is the main()
static class Program { static void Main() {
Dog james = new Dog();
MessageBox.Show(james.Frontleft.paws.cells.insideCell); }
}


it's actually an object within an object within an object...
but here is my problem.... How am I suppose to know this without having to look through the rest of the classes?????
I mean, why can't Microsoft make it easy and make a distinction between each one???? It's completely racking my brain!!!
Just by looking this line of code - no.
Mouse hover in VS (provided developer cared to give appropriate comments) - Yes

"why can't Microsoft make it easy and make a distinction between each one?"

Then you would rant why M$ doesn't let you name things in code the way you want.

"make it easy"

What was the first programming language you studied? Compare it with .Net + VS development and you will realize how easy this is.
 
Share this answer
 
Comments
wizardzz 10-Jan-11 14:52pm    
Good point on the hover over, was going to recommend it, too.
nic77m 10-Jan-11 14:53pm    
I'm assuming you're saying no....that it's not possible to know which of the 3 it could be.

I just don't get how hard it is to just distinguish the 3 when creating c# in the first place with a different symbol like...

james.Frontleft.paws.cells.insideCell
james/Frontleft/paws.cells/insideCell
james:Frontleft:paws.cells:insideCell

i studied C at school first. I understand the dot represents a pointer. So if I'm not mistaken, it could be possible that the first part of the text can be a namespace....and then the last part can be an object within an object within an object etc.?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900