|
In matlab (also other languages), there is a function called "eval" which can execute a command in a string, such as eval('plot(x,y)') is the same to plot(x,y).
Is there similar function in c#? if not, how to do then?
thanks.
|
|
|
|
|
The eval function is common in interpreted languages, but not in compiled languages.
In C# you would have to compile the code into a separate assembly, that you load and use. If I'm not mistaken, there is some article here on CP that describes this.
---
single minded; short sighted; long gone;
|
|
|
|
|
Without knowing the source, I would suspect that it is extremely unlikely that you are going to find this. What did google have to say?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Nothing on Google - nada. I can still use the code sample, but have to create my own db, perhaps use the Northwind db cistomers table.
|
|
|
|
|
I have an array of integer, how i can choose the bigest value in it ?
Thanks in advance
Assaf
|
|
|
|
|
looks like your having trouble in ur assignment
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
yeh,
i just think that maybe there is simple property for that
anyway thanks !
Assaf
|
|
|
|
|
You have many choices. You can iterate over it and store the largest value, or you could sort the array and choose the last (of first - depending on whether the sort was ascending or descending) entry. However, you are going to have to write the code for yourself.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Here's a couple of tips you can use:
1. create an array to hold your values
2. create an additional temporary array
3. iterate (for loop is preferable in your case)
4. in each loop, you'll have to compare a value from the array of original values with those already in the temporary array, and add it "sorting logic must be implemented here"
5. once sorted, simply pick the last value in the temp array by moving to its last index
another way to do it is to use two nested loops.
Good luck!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I found the DoubleClick event for Button does not work in Visual C#.
Although you can add the DoubleClick event handler but it does not work. Actually, in the event list, you can not find the DoubleClick event selection.
Any one can tell me whether I can realize the DoubleClick event for Button?
thanks.
|
|
|
|
|
The MouseClick property for a button accepts MouseEventArgs. These arguments contain a property called Clicks which identifies the number of clicks. However, for a button this is pretty much useless because the button is designed to respond to single clicks. Double click behaviour is outside the normal behaviour of a button.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
ConnectMe = new OracleConnection("Data Source=orcl; Persist Security Info=True;User ID=DLDSP; Password=DLDSP;Unicode=True");
ConnectMe.Open();
It has been working wonderfully for months and now I get this bloody message:
ORA-12535 TNS:operation timed out
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Sounds like your database server is down.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey Christian
Christian Graus wrote: Sounds like your database server is down.
You bet
I had to restore my system to an earlier point and it's fine now, thank you for taking the time to read this sh*t Christian
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have some code samples that uses the Cargo database, and for one or other reason I do not have the complete database. Can anyone provide me with a link where I can download this database.
Thanks
Pierre
the confused are confused beyond confusion
|
|
|
|
|
I've never heard of it. Where did the samples come from ? Did you try google ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have no idea. In my quest to get my hands on sample code, I have accumulated so may samples code, ePages etc. This seems to me from a book that have labs and or modules. The one module, Mod08 has three samples, DataFormWizard1, DataReader and XMLData. This is about all I know. And there is no indicatoion in the sample code wher it is coming from.
Thanks
P
|
|
|
|
|
I want to realize the following:
I have created several buttons, each of them has a name related to a function (i.e. the function name is the same to the button name). Now I want to call the corresponding function according to which button you click. Of course, you can not use "switch" or "if" conmmands to realize it. because the buttons as well as the funcitons are not fixed.
for example, I have buttons with name A, B, C,...
there are also the corresponding functions void A();void B(); void C();...
I want to call void A() if you click button with name of "A", I want to call void B() if you click button with name of "B", and so on.
Could you please give me an simple method for that?
thank you very much.
|
|
|
|
|
OK - assuming that your buttons and functions have better names than A, B and C, you could use reflection to handle this. Off the top of my head, I would expect that you could handle this with:
private void ButtonHandler(object sender, EventArgs e)
{
string name = ((Button)sender).Name;
this.GetType().InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] { });
} Then all you would need to do is wire up your buttons to this one event handler.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thanks a lot!
I will try it!
|
|
|
|
|
No problem.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
HI,
I'm using FtpWebRequest class to provide ftp communication in my application. All is fine, except it sometimes fails. I've tried everything what I could, it just sometimes fails - throws
System.Net.WebException: The remote server returned an error: (500) Syntax error, command unrecognized.
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
To be more specific - it is download command (WebRequestMethods.Ftp.DownloadFile).
It runs on a speparate thread in background worker, code :
<br />
FileStream clientStream = new FileStream(this.DestinationPath, FileMode.Create);<br />
FtpWebResponse response = (FtpWebResponse)this.Request.GetResponse();<br />
this.GotResponse = (response != null);<br />
<br />
Stream ftpStream = response.GetResponseStream();<br />
<br />
this.ContentLength = response.ContentLength;<br />
<br />
int bufferSize = 2048;<br />
int readCount;<br />
byte[] buffer = new byte[bufferSize];<br />
<br />
readCount = ftpStream.Read(buffer, 0, bufferSize);<br />
<br />
long dataTransfered = 0;<br />
<br />
while (readCount > 0)<br />
{<br />
if (this.Worker != null && this.Worker.CancellationPending)<br />
{<br />
canceled = true;<br />
this.Request.Abort();<br />
break;<br />
}<br />
<br />
this.CheckPause();<br />
<br />
lock (this)<br />
{<br />
this.lastLoadedSize += readCount;<br />
} <br />
<br />
dataTransfered += readCount;<br />
<br />
clientStream.Write(buffer, 0, readCount);<br />
<br />
if (this.ContentLength > 0)<br />
{<br />
int completed = Convert.ToInt32(((float)dataTransfered / (float)this.ContentLength) * 100);<br />
this.ReportProgres(completed);<br />
}<br />
<br />
readCount = ftpStream.Read(buffer, 0, bufferSize);<br />
}<br />
where this.Worker - Worker object that provides thread for running.
I dont know if it is a problem inside WebRequest class or in my code(where ???) .
Thanx for any help!!
|
|
|
|
|
Chances are the server doesn't understand one of the commands being sent. Check out this[^] for more information.
|
|
|
|
|
I can't open the link you posted.
|
|
|
|
|
I had a similar problem when accessing Microsoft's forums site through IE. Try flushing your cache (and delete any microsoft.com cookies) or switching browsers.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|