locked
How to solve the error CS1518? RRS feed

  • Question

  • Hi all, I am trying to read an XML file with my code. I am new to C# and I don't know how to solve the CS1518 error please help!

    This is my code:

     

     

    using System;

    using System.Data;

    public string Namespace {get;set;}

    public class ChangeSource

    {

    static void Main()

    {

    DataSet ds = new DataSet();

    ds.ReadXml(@"d:\dennis\work\ari\rsscripter\testscript 1.06\cashier\cashier analysis.rdl");

    strNow = ds.Tables[1].Rows[0][0].ToString();

    MessageBox.Show(strNow);

    strNow = ds.Tables[1].Rows[0][1].ToString();

    MessageBox.Show(strNow);

    ds.Tables[1].Rows[0][1] = new_value;

    }

    }

     

    and this is my error message:

    "change_source.cs(3,8): error CS1518: Expected class, delegate, enum, interface, or struct"

     

    If anyone know how the solution for this error, please help! Thank you!

     

    Grace be to you all.

    Dennis

    Wednesday, May 19, 2010 12:07 AM

Answers


  • You have declared a string property named Namespace outside of any class, which is an error.  Move it to within a class.

    --
    Mike
    • Proposed as answer by Olaf Rabbachin Wednesday, May 19, 2010 6:55 AM
    • Marked as answer by Harry Zhu Wednesday, May 26, 2010 8:09 AM
    Wednesday, May 19, 2010 12:18 AM

All replies


  • You have declared a string property named Namespace outside of any class, which is an error.  Move it to within a class.

    --
    Mike
    • Proposed as answer by Olaf Rabbachin Wednesday, May 19, 2010 6:55 AM
    • Marked as answer by Harry Zhu Wednesday, May 26, 2010 8:09 AM
    Wednesday, May 19, 2010 12:18 AM
  • using System;
    
    using System.Data;
    
    public string Namespace
    
    {
    
    public class ChangeSource
    
    {
    
    static void Main()
    
    {
    
    DataSet ds = new DataSet();
    
    ds.ReadXml(@"d:\dennis\work\ari\rsscripter\testscript 1.06\cashier\cashier analysis.rdl");
    
    strNow = ds.Tables[1].Rows[0][0].ToString();
    
    MessageBox.Show(strNow);
    
    strNow = ds.Tables[1].Rows[0][1].ToString();
    
    MessageBox.Show(strNow);
    
    ds.Tables[1].Rows[0][1] = new_value;
    
    }
    
    }
    
    }
    


    My .NET Blog: http://michaelcrump.net
    Saturday, May 29, 2010 4:47 AM