Home c# Analog (Similarity) Include in C #

Analog (Similarity) Include in C #




(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 …

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 .

  1. Create a new file
  2. Copy structure / class
  3. at the place of use Add a string that will import namespace .

For example:


namespace xxx
  Public Class Class {}


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.

  1. Create a new file (for example, My.cs)
  2. Copy structure / class (see Question).
  3. Add file to solution:
    In the PCM Solution Explorer Add- & GT; Existing Element (Add – & GT; Existing Item) – & gt; You choose your file

  4. At the place of use of add a string that will import Namespace:

using mynumbrasses;
  1. I also add that in this file you need to duplicate directives using the main part !!!
    That’s just then get a full include !!!

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions