Hi, I am coding two .cs files into one dll but Visual Studio 2012 sends the following error message:
The name 'Beeper' does not exist in the current context.
The first file codes like this:
publicvoid Beeper(long frequency, int msDuration, long volume)
//Stream a tone of specified frequency...
When I do the function call in the second .cs file:
Singer cacophony = new Singer();
int Duration = 300000;
//Generate frequency for nw
ThreadStart Wfrequency = new ThreadStart(Beeper(nw, Duration, 16383));
Thread childThreadW = new Thread(Wfrequency);
//Generate frequency for nw
It gives the error.
I know I am missing something very basic.
Thanks for the help.
Beeper is a member function of Singer (the class)... Calling it like Beeper alone will only work when you are in the context of Singer (from other members for instance).
If you are out of that context you have to tell the compiler the new/actual context... in your case cacophony...
So the code should be like this:
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
You really need to understand the basics of c# before you try anything half-way complicated. We can't solve every basic problem you have. Get a book on c# and learn the fundamentals so you can solve these issues yourself, a forum is not a good place to learn something from scratch.
Yes, what you are creating here is a delegate, not an immediate call to the beeper method. You need to spend more time reading the links you have been given to understand how delegates are used. See the tutorials on Events and Delegates at C# Tutorials (C#)[^].
While I'm generally in favor of Controls letting the user do anything ... and, then, pay the price for doing something stupid, I'm just curious if the WPF and ASP.NET Controls allow the same.
I have a bright student who keeps asking me why they can create multiple nodes whose text (what appears on the Node Label) is identical; I tell them: "you think that's crazy: how about an entire TreeView where every Node has both identical Text and Name (Key) values ?" Then, I show them how to create a sub-classed TreeView that prevents identical Text, or Name (Key) values.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
I have a bright student who keeps asking me why they can create multiple nodes whose text (what appears on the Node Label) is identical
..because that would be a limitation that does not bring us much in return, but it would be easy to prevent loading duplicates yourself.
I agree that the user should be able to uniquely identify an item before interacting with it; a identity-column should not be visible and is not enough for a user to distinguish between items - so, how do you convey that there are three fields in your view that make an item unique?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]