Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2008

Tip: Looking for answers? Try searching our database.

VS C# 2008 Object Reference Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 20 May 2008 00:20 GMT
The snippet below is from a small console app I'm playin' around with in C#.
Upon building the app, I receive the error message "An object reference is
required for the non-static field, method, or property
bla.bla.ConvTempoToMilliseconds(int)".

int tempo = Convert.ToInt32(args[1]);

// ERROR on following line

display(ConvTempoToMilliseconds(tempo));

return;

}

public int ConvTempoToMilliseconds(int tempo)

{

// duration = 60000 / tempo

return 60000 / tempo;

}

Thanks for your thoughts,

Mike
Lee - 20 May 2008 02:00 GMT
> The snippet below is from a small console app I'm playin' around with in C#.
> Upon building the app, I receive the error message "An object reference is
[quoted text clipped - 24 lines]
>
> Mike

You've defined ConvTempoToMilliseconds as an instance method -- you
need an instance of the class containing it in order to reference it.
If you want to be able  to reference the method then add 'static' to
its declaration -- public static int. Note that in you will then have
to reference it by its class-name.

--
Lee Silver

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.