(please do not delete the question. no clearly formulated.)
How to highlight your structures and classes to separate files!? To then be
using myclass.sharp;
or somehow differently …
UPD
For clarity:
My.cs file with user (own, new) classes:
namespace mynumbrasses // My classes
{
Public Class Mynumblass // My class
{
Public MynumberClass ()
{
}
}
}
No matter how I do does not help using Mynumbrasses. Writes an error !!!
using my.cs;
using mynumclasses;
does not work in any way.
Maybe the file needs to put somewhere?
Main file “Form1.cs”:
....
Using System.Net; // WebClient
using mynumclasses;
....
Namespace windowsFormsapp1
{
Public Partial Class Form1: Form
{
Public MynumberClass Tttest;
Public String SMESSAGE = "NULL";
....
Failed to find the type or name of the namespace “MyNumberCase” (possibly missing directive using or link to the assembly)
Answer 1, Authority 100%
In C # Using
, it does not work as include
in C++. using
does not import a specific class, and a whole Namespace .
- Create a new file
- Copy structure / class
- at the place of use Add a string that will import
namespace
.
For example:
class.cs
namespace xxx
{
Public Class Class {}
}
Program.cs:
using xxx; // Using may not be needed if both classes are in one namespace.
Namespace yyy.
{
Public Class Program {} // Here you can use your class
}
Answer 2
You have a class that is in a specific namespace
, for example:
namespace myapp.data
{
Public Class MyDataclass.
{
// Implementation
}
}
In order to create this instance of this class in another project file, you will need to “connect” it using using
Pointing Namespace
, in which the class you need, for example :
using myapp.data;
Namespace myapp.main.
{
Public Class Mainclass.
{
Public Void Method ()
{
var data = new mydataclass ();
}
}
}
Answer 3
Thank you Grundy, public full answer:
In C # using it does not work as include in C++. Using does not import a specific class, but a whole namespace.
- Create a new file (for example, My.cs)
- Copy structure / class (see Question).
-
Add file to solution:
In the PCM Solution Explorer Add- & GT; Existing Element (Add – & GT; Existing Item) – & gt; You choose your file -
At the place of use of add a string that will import Namespace:
using mynumbrasses;
- I also add that in this file you need to duplicate directives using the main part !!!
That’s just then get a full include !!!