Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling another class in another .cs file
Message
 
À
02/08/2002 11:20:57
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00685474
Message ID:
00685494
Vues:
14
You need to use "using namespace1;" in top of your .cs file
using System;
using namespace1;

public class myclass2
{

public static void Main ()
{
/// Access any exposed methods or properties of myclass1 like
myclass1 obj = new myclass1();
obj.mymethod();
}

}
>Using C#.
>
>How can I access another class in a different .cs file.
>
>For example, how can I get myclass2 in namespace2 to access something in myclass1 namespace1?
>
>////////////////////////////////
>//one.cs
>using System;
>
>namespace namespace1
>public class myclass1
>{
> public string mystring = ""
>}
>////////////////////////////////
>
>////////////////////////////////
>//two.cs
>using System;
>
>namespace namespace2
>public class myclass2
>{
>
>public static void Main ()
>{
>///Access namespace1.myclass1 in one.cs here.
>}
>
>}
>////////////////////////////////
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform