| | |
[ASK] C# Namespace Problem
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
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 26 Days Ago
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; 26 Days Ago 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 26 Days Ago
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 26 Days Ago
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; 26 Days Ago 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: Using Word._Application.Quit Method
| Thread Tools | Search this Thread |
.net access algorithm angle array barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion convert csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum event excel file firefox form format forms function gdi+ httpwebrequest image index input install java label leak libraries list listbox mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






