O
O
Ostic2020-02-02 11:48:59
C++ / C#
Ostic, 2020-02-02 11:48:59

How do namespaces work in C#?

Hello.
Namespace question.
for example the structure is:

using System;
namespace Life 
{
class CommonFeatures
  {
    //public void Main(){}
    public static void sayHello()
    {
      Console.WriteLine("I'm a creature...");
    }
  }
  ////////////////////////////
  namespace Peoples
  {
    class Man
    {
      // public void Main() {}
      public static void sayHello()
      {
        Console.WriteLine("Hello...");
      }
    }
  }
  ////////////////////////////
  namespace Animals
  {
    public class dog
    {
      public static void Main()
      {
        Life.Peoples.Man.sayHello();
        Life.CommonFeatures.sayHello();
        sayHello();
      }
      public static void sayHello()
      {
        Console.WriteLine("Gav, Gav...");
      }
    }
  }

}

why, if CommonFeatcher or Man write public and add Main, then the output is zero - just nothing happens?
Type entry point should be one?
How to refer to namespaces without constantly writing out the whole chain like ABCD ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Ostic, 2020-02-02
@Ostic

from what I understand:
you need to create an alias at the very beginning (which is inconvenient, IMHO)
can't you do it somehow directly in the context, inside a class or method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question