| | |
[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 24 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; 24 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 24 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 23 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; 23 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 array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development draganddrop drawing encryption enum excel file filename finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile gis globalization gtk httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






