|
I'm not 100% sure of this one, but I think it should be:
Public Function GetCallbackResult() As String Implements _
System.Web.UI.ICallbackEventHandler.GetCallbackResult
End Function
public override string GetCallbackResult() This is inheritance of both a base class and an interface, which uses the same syntax.
Partial Class
Inherits System.Web.UI.Page
Implements System.Web.UI.ICallbackEventHandler
partial class : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler C# doesn't allow optional parameters. You achieve this by creating overloads on the function. In this case, the "shorter" function just calls the "longer" one and passes the parameters along with the default value for MaxRows.
Public Shared Function GetInfoByDate(ByVal Id As Integer,
ByVal ToDate As Date,
Optional ByVal MaxRows As Integer=0)As SqlDataReader
End Function
public static SqlDataReader GetInfoByDate(int id, Date toDate)
{
return GetInfoByDate(Id, ToDate, 0);
}
public static SqlDataReader GetInfoByDate(int id, Date toDate, int maxRows) Also, note the syntax difference. C# is a case-sensitive language, unlike VB.NET.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
hi.Scott..,
thank u very much for help...it was great...
---------------------------------
In just second,it will be past also..
|
|
|
|
|
***********************************************
good artical regarding this....
http://msdn2.microsoft.com/en-us/library/ms178208.aspx
|
|
|
|
|
I have a scrollable pane with images in it.
I would like to move the contents of the pane from a function.
The only thing I have found so far is to call performScrollHorizontal several times.
Ideally I would like to call scrollable.panel.hPos = 4711 or somthing like that.
I tried using SetScrollPos but that only moved the scrollbar not the content.
Any tips to where I should start looking next?
|
|
|
|
|
Guys,
A few days ago I asked about an assignment we had to do here at work. convert "aabb" to "aAbB" and set it to the textbox as quickly as possible. I think the conversion itself is very quick, reading in and converting in 1 or 2 seconds, but setting the entire thing in the texbox takes me another 10 seconds! (20 MB file)
I've read about the AppendText property and tried to set my characterarray to the box inside my loop, but so far the fastest results I got where form txtbox_result.Text = new string(text); where text = char [].
Any ideas on how to speed this up? (Suspend/resumelayout don't help either)
thanks !
PS: here's tho code I got so far:
starttime = DateTime.Now;
reader = new System.IO.StreamReader(openfiledlg.FileName);
char [] text = reader.ReadToEnd().ToCharArray();
reader.Close();
difference = DateTime.Now - starttime;
lbl_result.Text = "File read: " + difference.TotalMilliseconds + " milliseconds.";
lbl_result.Refresh();
pb_conversion.Maximum = text.Length;
int i2 = 0;
for(int i = 1; i < text.Length; i+=2){
text[i] = char.ToUpper(text[i]);
if(++i2 == 1000){
i2 = 0;
pb_conversion.Value = i;
}
}
difference = DateTime.Now - starttime;
lbl_result.Text = "conversion: " + difference.TotalMilliseconds + " milliseconds.";
lbl_result.Refresh();
pb_conversion.Value = pb_conversion.Maximum;
txtbox_result.SuspendLayout();
txtbox_result.Text = new string(text);
txtbox_result.ResumeLayout();
difference = DateTime.Now - starttime;
lbl_result.Text = "Done in: " + difference.TotalMilliseconds + " milliseconds.";
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
Do you really need all this text in a textbox?
If you really do, I would consider loading a small portion of text first and then appending the rest in a separate thread.
|
|
|
|
|
lol, it's a test at work and one of the requirements was, show conversion in a textbox.
I don't think that this one will work because timing only counts when everything is done. Good idea though. tnx.
|
|
|
|
|
The textbox aren't really designed for holding 20MB of text.
Try opening the file in notepad and see how much time it take.
A RichTextBox might be a better choice in your case.
|
|
|
|
|
.jpg wrote: The textbox aren't really designed for holding 20MB of text
He he, don't tell me .
the rich textbox does give a slight improvement .
|
|
|
|
|
I'm not too sure about putting text into a textbox quicker, but if you definately know that every 2nd character is a letter, then using
text[i] = (char)((int)text[i] - 32);
is quicker than using
text[i] = char.ToUpper(text[i]);
|
|
|
|
|
if(char.IsLetter(text[i])){
text[i] = (char)((int)text[i] - 32);
}
gained me 1 second thanks
(this is actually kinda fun , I learned a lot here... )
|
|
|
|
|
You could even call your progress bar update fewer times than you are, with a 20 meg file you're currently calling the progress bar update more than 20,000 times.
If this takes 10 secs to go through the for loop, that's 2000 progress bar updates per second, bit of overkill there.
|
|
|
|
|
Unfortunately this will only work for ANSI characters, so you're actually introducing a bug in order to gain a few ms...
Not a good deal IMHO.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
It's not introducing a bug, if you had read the original thread from a few days ago you'd realise that this is what the OP wanted - 'convert "aabb" to "aAbB" and set it to the textbox as quickly as possible'.
Thanks.
|
|
|
|
|
Ok, if it's really just A's and B's then it'll work of course.
I guess I'm already going on auto when seeing someone performing integer maths on characters
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I am not surprised it is faster as ToUpper actually converts to upper case.
Subtracting 32 works in a limited subset of letters (the A-Z range and a few others), and it ignores cultural settings. Sure it might be fine enough for a "just for the fun of it" project like this, but unfortunately people end up beleiving they actually can convert using code like this in real projects as well.
|
|
|
|
|
Instead of using
txtbox_result.Text = new string(text);
Do this
txtbox_result.AppendText(new string(text));
|
|
|
|
|
tnx, good idea, but didn't help.
|
|
|
|
|
I can process a 20 meg file and display it with appendtext in 4 seconds.
|
|
|
|
|
mine is, with ngen and Highest priority thread about 16 seconds. Maybe you have more memory and faster cpu? (Centrino 2,13GHz, 2Gb memory)
|
|
|
|
|
Here's my code.
I'm using a standard textbox.
textBox2.Clear();
DateTime dt = DateTime.Now;
StreamReader sr = new StreamReader(@"C:\test\test.txt");
char[] c = sr.ReadToEnd().ToCharArray();
progressBar1.Maximum = c.Length;
for (int i = 0; i < c.Length; i += 2)
{
if ((int)c[i] >= 97 && (int)c[i] <= 122)
c[i] = (char)((int)c[i] - 32);
if (i % 10000 == 0)
progressBar1.Value = i;
}
textBox2.AppendText(new string(c));
MessageBox.Show((DateTime.Now.Ticks - dt.Ticks).ToString());
Note that a textbox does only store 32k of text, but if your assignment says you just have to fill a textbox, then you are only doing what it says...
|
|
|
|
|
thanks, i'll try this tomorrow. Last day for submitting our tries .
Maybe I'll post in the lounge next week how I did (or we did )
|
|
|
|
|
I have PDF documents and I must print them directly from a C# program.
I must do it from my C# program under .NET 1.1.
Can somebody help me ?
Thank you in advance,
Patrick Meinguet
|
|
|
|
|
You can always use the Process object. The code would be something like:
System.Diagnostics.Process p = new System.Diagnostics.Process;
p.StartInfo.Verb = "print";
p.StartInfo.FileName = "putthefilenamehere";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = true;
p.Start();
System.Threading.Thread.Sleep(5000);
p.Close();
Hope that helps.
Ben
|
|
|
|
|
Hi All
I am a new to C# and to programming . My first job. I want to get some things right. The coding that i am doing will go in for a code review and it will be my first one.
The problem is that i am creating a control at run time and registering an event to take care of click event
like belwo
GridVoucher.Click += new GridClickEventHandler(GridVoucher_Click);
i may want to dispose off the control also !!
Do I unregister this event before I dispose of the code (I think i should)
If so how ? I know I am suppose dto use the -= operator but how?
I am confused
Can somebody help ?
Thanks
Romi
|
|
|
|