developer
developer

Reputation: 7400

create a namespace in c++/cli?

I have seen many examples of using .NET Framework namespaces in c++/cli like the following:

using namespace System;
using namespace System::IO;

But I haven't seen any examples of creating my own. So I was wondering if there is a way to declare/create my own namespace as I would in C#:

namespace Animals
   {

   public class Dog
       {
       public Dog() {}
       }
   }

Thanks for your time :)

Upvotes: 3

Views: 5854

Answers (2)

Ed Bayiates
Ed Bayiates

Reputation: 11210

Same syntax for single namespaces. Nest for multiples, e.g. for First.Second.Third:

namespace First
{
namespace Second
{
namespace Third
{

    // Your code

}
}
}

In C# the same would be:

namespace First.Second.Third
{
}

Upvotes: 9

Armen Tsirunyan
Armen Tsirunyan

Reputation: 132994

You already know how it should be done, as is demonstrated by your example

namespace NamespaceName //C++/CLI or C#
{
    //contents
}

Upvotes: 2

Related Questions