Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#



using System;
using System.Xml;

namespace ReadXml1
{
    internal class Class1
    {
        private static void Main(string[] args)
        {
            // Create an isntance of XmlTextReader and call Read method to read the file
            XmlTextReader textReader = new XmlTextReader(@"C:\Users\LK\source\leek");
            _ = textReader.Read();
            // If the node has value
            while (textReader.Read())
            {
                // Move to fist element
                textReader.MoveToElement();
                Console.WriteLine("XmlTextReader Properties Test");
                Console.WriteLine("===================");

                // Read this element's properties and display them on console
                Console.WriteLine("Name:" + textReader.Name);
                Console.WriteLine("Base URI:" + textReader.BaseURI);
                Console.WriteLine("Local Name:" + textReader.LocalName);
                Console.WriteLine("Attribute Count:" +
 
                 textReader.AttributeCount.ToString());

                Console.WriteLine("Depth:" + textReader.Depth.ToString());
                Console.WriteLine("Line Number:" + textReader.LineNumber.ToString());
                Console.WriteLine("Node Type:" + textReader.NodeType.ToString());
                Console.WriteLine("Attribute Count:" + textReader.Value.ToString());
            }
        }
    }

}


What I have tried:

I seem that I cant understand what the real issue is with my code
The Console.WriteLine is an error more specific WritLine is underlined nothing else. The error is WriteLine can not be used like a method.
Posted
Updated 28-Oct-21 0:21am
v3
Comments
phil.o 28-Oct-21 6:17am    
Did you place that code in a console application? Or in another type of VS project?
Govancekaran 28-Oct-21 6:56am    
in console application
BillWoodruff 28-Oct-21 8:21am    
Put breakpoints in the code and single step (F11) through it, examining the state of variables.

1 solution

That code does not generate any compiler errors or warnings: it compiles cleanly.

It can't be run on my system, because I do not have access to your data file, but I would suspect you are working with different source code to that you have shown us, or the error is coming in a different file in the same project.

CS1955 occurs when you try to use a property, field, or variable as a method and append brackets to call it: myObject.MyProperty();
 
Share this answer
 
Comments
Govancekaran 28-Oct-21 6:58am    
the error is coming from this project non other, I did check that before I started to research online.
OriginalGriff 28-Oct-21 7:15am    
A Project has (normally) multiple .CS files, it isn't the same as a "file containing C# code).
And a Solution can contain multiple Projects, each with separate .CS files.

Just because "this project" has the error, that doesn't mean it's in the same file That you show.
Govancekaran 28-Oct-21 7:03am    
how should I rewrite the code so it doesn't give me that error type?
OriginalGriff 28-Oct-21 7:13am    
How do you expect us to know, if the code you show us doesn't generate the error code at all? :laugh:

Double click the error message in VS and it'll take you direct to the line. Compare that with what you showed us!
Govancekaran 28-Oct-21 7:18am    
it took me to WritLine(because it cant be used as a method) as i said (when i clicked twice)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900