Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2003, 12:45 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to shortynelson Send a message via Yahoo to shortynelson
Default namespace

Hi everybody. I think it is quite silly that I ask this question, but, it is really a big problem for me.

I have been trying to write 2 classes declaring namespace.

//Compile using --> csc /target:library myClass.cs
namespace testing{
  public class myClass{
    public string myFunc(){ return "Returned String"; }
  }
}
//End of myClass

//Compile using --> csc testMyClass.cs
using System;
using testing;

public class testMyClass{
  public static void Main(String[] args){
    myClass mc = new myClass();
    Console.Writeline(mc.myFunc());
  }
}
//End of testMyClass

When compile the testMyClass.cs, compiler complains that it couldn't find the namespace 'testing' with the bracket "are you missing a using directive or an assembly reference". Why is that so? Do I need to set any classpath like in Java? If not, how should I solve this problem? Anyone please help....

Nelson Chan
 
Old September 9th, 2003, 01:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Nelson,

You'll need to refer the compiler to the DLL you created from your first compilation, by using /r:YourDLLName.dll. So this would work:

csc /r:myClass.dll testMyClass.cs

Don't forget to change Writeline to WriteLine in the second source file.....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 9th, 2003, 03:14 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to shortynelson Send a message via Yahoo to shortynelson
Default

Dear Imar,

Thanks for your help! It works.

Nelson Chan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Two namespace contain same name nir_pankaj C# 1 February 21st, 2007 12:30 PM
namespace Ibn_Aziz C# 2 December 25th, 2003 05:41 AM
namespace within namespace Bill Crawley XML 1 December 11th, 2003 10:59 AM
Namespace flute Pro VB.NET 2002/2003 2 October 21st, 2003 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.