Les sous-routines en C#

Je suis un peu novice en C#, et pas tout à fait sûr de savoir comment appeler une sous-routine. Voici ce que j'essaie de faire:

private void button1_Click(object sender, EventArgs e)
{
    //Call whatever subroutine you like
    StartExstream();
}

public void StartExstream()
{
    //Do Stuff Here
}

Malheureusement pour moi, cela ne fonctionne pas. Je suis un "Seule la cession, l'appel, incrémentation, décrémentation, et de nouvelles expressions d'objet peut être utilisé comme une déclaration d'erreur".

Comment dois-je appeler mon StartExstream sous de mon événement Button1_Click?

Grâce,
Jason

EDIT:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        //Call whatever subroutine you like
         StartExstream();
    }



    public void StartExstream()
    {
        tcpExstream.Service1Client MyTCP = new tcpExstream.Service1Client();

        string ExStreamPath;
        string datPath;
        string optPath;

        //My Working Arguments
        ExStreamPath = @"C:\Program Files\Exstream\Dialogue 6.1\Engine.exe";
        datPath = @"-FILEMAP=DataFile,\\Dev-srv1\Exstream\LetterWriterApp\Input Files\Data Files\SAVEezkazivaftf40s452ndayb45.dat";
        optPath = @"-CONTROLFILE=C:\Exstream\Development\LetterWriter\ControlFiles\Letter.opt";

        //Hong's Arguments
        //ExStreamPath = @"C:\Program Files\Exstream\Dialogue 6.1\Engine.exe";
        //datPath = @"-FILEMAP=DataFile,C:\Exstream\development\AGDocGenerator\TempFiles\DataFiles\Data_456231_1598.xml";
        //optPath = @"-CONTROLFILE=C:\Exstream\development\AGDocGenerator\ExstreamDialogue\ControlFiles\AGDocGenerator.opt";

        //Kick It!
        MyTCP.StartExStream(datPath, optPath, ExStreamPath);

        //Extra line of code for breaking point
        optPath = "nothing";
    }
}

}

  • Sont-ils dans la même classe?
  • Le Code a l'air bien, vous devez avoir omis de mentionner le code avec le problème
  • Poste le code complet de la classe. Le code que vous avez ici semble parfait.
  • Je ne vois aucun problème dans votre code. Merci de poster le code complet de l'appelant et de l'appelé si vous voulez que les gens d'ici pour vous aider.
InformationsquelleAutor | 2011-06-10