Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileInfo.Name() 1

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
Hello,

sorry, crap question, but in the o'reilly nutshell book C#, it names a method as -- "FileIno.Name{get}" ... whats the 'get' about ?! If I call FileIno.Name() - it throws a compiler error ....

I try

<code>
FileInfo fi = new FileInfo(&quot;C:\readme.txt&quot;);
Console.Write(fi.Name());
</code>

and get ::
<code>
Hello.cs(13,19): error CS0118: 'System.IO.FileSys
'property' where a 'method' was expected</code>

Any ideas ?
 
By appending () to the end of Name you are invoking a method rather than trying to get a property. Try this:

<code>
FileInfo fi = new FileInfo(&quot;C:\readme.txt&quot;);
Console.Write(fi.Name);
</code>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top