dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: [RESOLVED] new operator problem?

Threaded View

  1. #1
    Join Date
    Jan 2011
    Location
    Vilnius/Utena, Lithuania
    Posts
    14

    [RESOLVED] new operator problem?

    Code:
    namespace ...
    {
    public partial class Form1 : Form
    {
    .
    .
     private void textBox1_DragDrop(object sender, DragEventArgs e){
        string[] failas = (string[])e.Data.GetData(DataFormats.FileDrop);
        foreach (string failas_ in failas){
          Failas cfailas = new Failas(); //////////////////////////////////////////////////
          cfailas.setfile(failas_); //////////////////////////////////////////////////
          label2.Text = cfailas.failas;  ////////////////////////////////////////////////// <<<<<<< EVERYTHING IS OK
          textBox1.Text = cfailas.split_filename(failas_);
        }}
    .
    .
     string password = "";
     private void button2_Click(object sender, EventArgs e) {
      if (password == "")  {
        password = textBox2.Text;
        textBox2.Clear();
        label2.Text = "Pakartokite slaptažodį:";
      }
      else if (label2.Text == "Pakartokite slaptažodį:" && password == textBox2.Text){
        Failas cfailas = new Failas(); //////////////////////////////////////////////////
        label1.Text = cfailas.failas;  ////////////////////////////////////////////////// <<<<<<< IS EMPTY
        textBox2.Clear();
        password.Remove(0);
      }}
    }
    
    class Failas
    {
     public string failas; //////////////////////////////////////////////////
     public void setfile(string a){ failas = a;} //////////////////////////////////////////////////
     public string split_filename(string a){
      string[] b;
      b = a.Split('\\');
      return b[b.Length - 2] + "\\" + b[b.Length - 1];
     }
    }
    }
    Why variable "failas" is empty in "Failas" class when I set it in one function, but read from other?
    Last edited by Migeria; May 17th, 2011 at 05:28 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)