| | |
[ASK] C# Namespace Problem
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi, I've code like this
when I want to use the Karyawan's Class in User's Class
why I used to write Karyawan two times, Karyawan.Karyawan not just Karyawan?
Thanks.
C# Syntax (Toggle Plain Text)
namespace RestaurantSoftClassLib.Karyawan { public class Karyawan { blablabla } }
when I want to use the Karyawan's Class in User's Class
C# Syntax (Toggle Plain Text)
using RestaurantSoftClassLib.Karyawan; namespace RestaurantSoftClassLib.User { public class User { Karyawan.Karyawan karyawan; blablabla } }
why I used to write Karyawan two times, Karyawan.Karyawan not just Karyawan?
Thanks.
0
#2 Nov 1st, 2009
Hello.
That's weird .. works fine for me when I use this:
and then
Try to remove one
That's weird .. works fine for me when I use this:
c# Syntax (Toggle Plain Text)
using RestaurantSoftClassLib.Karyawan;
c# Syntax (Toggle Plain Text)
Karyawan karyawan;
Try to remove one
Karyawan .. what's happening if you use only one? Last edited by Antenka; Nov 1st, 2009 at 4:47 pm.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#3 Nov 2nd, 2009
Try to remove one
if I remove one there is an error like this
"Error 1 'RestaurantSoftClassLib.Karyawan' is a 'namespace' but is used like a 'type' C:\Documents and Settings\sky\My Documents\Visual Studio 2008\Projects\RestoranSoft\RestaurantSoftClassLib\User\User.cs 18 9 RestaurantSoftClassLib"
Karyawan .. what's happening if you use only one?if I remove one there is an error like this
"Error 1 'RestaurantSoftClassLib.Karyawan' is a 'namespace' but is used like a 'type' C:\Documents and Settings\sky\My Documents\Visual Studio 2008\Projects\RestoranSoft\RestaurantSoftClassLib\User\User.cs 18 9 RestaurantSoftClassLib"
0
#8 Nov 2nd, 2009
Hello.
Or use
In your code the
Because the
But since the
So if you restrict the scope of using directive to particular namespace - it would work just fine
Or use
using directive inside of target namespace: c# Syntax (Toggle Plain Text)
namespace RestaurantSoftClassLib.User { using RestaurantSoftClassLib.Karyawan; class User { Karyawan karyawan; } }
In your code the
RestaurantSoftClassLib is visible even without this: c# Syntax (Toggle Plain Text)
using RestaurantSoftClassLib.Karyawan;
User namespace is inside RestaurantSoftClassLib . And if you remove this using - there will be no effect. I'm not sure, but suppose that this relationships are more significant and the code, when you're trying to make a reference on RestaurantSoftClassLib.Karyawan is just being ignored. But since the
User is aware of RestaurantSoftClassLib - it has no idea about Karyawan.So if you restrict the scope of using directive to particular namespace - it would work just fine
Last edited by Antenka; Nov 2nd, 2009 at 6:45 am. Reason: Forgot ...
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
![]() |
Other Threads in the C# Forum
- Previous Thread: Programming Live Chat
- Next Thread: hi..
Views: 311 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box button buttons c# chat check checkbox class client code color combobox control conversion csharp custom database datagridview dataset datetime degrees draganddrop drawing encryption enum excel file files form format forms ftp function gcd gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






