B
B
baursak2015-11-28 16:12:28
C++ / C#
baursak, 2015-11-28 16:12:28

How to create a simple template in Visual Studio without a Namespace?

Good afternoon everyone.
I am new to C#.
Both the IDE and the syntax of the language for me are not yet the area where I am strong.
From several video courses, according to a number of criteria, I have chosen this one ("Learning Path: C#" by Eric Lippert, 2015).
I don’t want to bother much with the details yet, but in a simple way, like his, I can’t always figure out how to do it.
How, for example, to remake a template in MS VS to create a class WITHOUT namespace (here https://yadi.sk/d/XdgIZU6gkodLc 2 screenshots, which, I hope, you can understand: what MS VS offers and what I want).
=====================
1) go here:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates\CSharp\Windows Root \Windows\1033\ConsoleApplication
2) change this text of the program.cs template:
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
$endif$
namespace $safeprojectname$
{
class Program
{
static void Main(string[] args)
{
}
}
}
3) to this program.cs template text:
using System;
class Program
{
static void Main(string[] args)
{
}
}
enjoy the simplicity of a lightweight template

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Kovalsky, 2015-11-28
@dmitryKovalskiy

What do you understand by "Class without namespace"? It's technically impossible. Yes, and why you do this, I can not understand.

M
Melz, 2015-12-03
@melz

It's useless
Regardless of whether a namespace is explicitly declared in a C# source file, the compiler adds a default namespace. This unnamed namespace, sometimes called the global namespace, exists in every file. Any identifier in the global namespace is available for use in any named namespace.
this is from the documentation .
2. Use the code tag around the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question