Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Créer les types d’objet localement ou à distant

Charger,une,Assemblée,avec,un,nom
{filelink=17560}

using System;
using System.Reflection;
using System.Text;
 
public class MonType
{
    public void Afficher(int x)
    {
        Console.WriteLine(x);
    }
}
 
public class Example
{
    static void Main()
    {
        Object o = Activator.CreateInstance(typeof(StringBuilder));
        StringBuilder sb = (StringBuilder) o;
        sb.Append("Bonjour, là.");
        Console.WriteLine(sb);
 
        System.Runtime.Remoting.ObjectHandle oh = Activator.CreateInstanceFrom(Assembly.GetEntryAssembly().CodeBase, typeof(MonType).FullName);
 
        MonType st = (MonType) oh.Unwrap();
 
        st.Afficher(5);
    }
}

No comments yet.

Leave a Comment