|
ham rez wrote: how can i draw address dynamicaly in c# similar paint brush
what does it mean ?
ham rez wrote: (draw line,rectangle,text,...)
using System.Drawing
cheers,
Abhijit
|
|
|
|
|
Stupid question, I admit, but I'm quite new to C#: how can I write a method which accepts a single input parameter or a collection (e.g. array) of this parameter?
For example, let's say I have the method void MyMethod(int[] args) . If I try to call the function with a single argument, like MyMethod(1234) , the compiler obviously throws an error (int != int[]).
Overloading surely solves the issue (i.e. defining both void MyMethod(int[] args) and void MyMethod(int arg) and factoring out the common behaviour in a different private method) but is there a simpler way to do this?
Regards,
Andrea
|
|
|
|
|
I think I've just found the answer by myself: void MyMethod(params int[]) .
It was a stupid question, indeed!
Bye,
Andrea
|
|
|
|
|
that was not a stupid question, it was just simple, sometimes you want to find something that you can describe it to a person but can not describe it to a search engine
I Wish the Life Had CTRL-Z
Wizard's First Rule : People are fool,they believe what they want to believe or what they afraid to believe
www.subaitech.blogspot.com
|
|
|
|
|
Yes, that's how I'd go, but you could also overload the method, have both methods.
Oh, of course, you said that. What I should add, is that with overloading, you don't need to "factor out to a private method", you could simply have one method call the other:
void MyMethod(int[] args) { ... }
void MyMethod(int arg) { MyMethod ( new int[] { arg } ) ; }
And leave all the functionality in the one main method. I rarely have to resort to a private method.
|
|
|
|
|
Metal76 wrote: It was a stupid question, indeed!
Not at all, the solution is not very obvious. It might not be the entire solution, either.
You may want to overload that method with one that takes a single int , that way you can call it without having the compiler generate code that creates an array object every time (for the params array). Perhaps also add overloads that takes two and three parameters. The string.Concat method is overloaded in that way, for example.
Another overload that you may want to add is one that takes an IEnumerable<int> , that will work for an int[] , but also for other collections, like a List<int> .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i've made 3 methods and all the 3 methods are very heavy weight code as the download htmldata so applied threads on each method
using
ThreadStart starter = delegate
{
the method called here
};
new Thread(starter).Start();
and used
progressBar1.Maximum = 100;
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
backgroundWorker1.RunWorkerAsync();
like this i've used 3 backgroundworker for all three methods separately
but still after the 3rd backgroundworker progressbar completes but the threads are still running so now i just want to know how can i make the UI thread responsive till all threads complete asynchronously.
your all advice are appreciated!!
cheers
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
Hi,
please publish actual code, not something that resembles your code but would by no means compile.
Why are you using a Thread AND a BackgroundWorker (3 each), just have the job done by the BGW,
it can both execute the job and report progress.
|
|
|
|
|
Technobizz,
Like Luc said, show some actual code. Also, how do you update the progress changed?, do you just pass it the current position in the iteration (i am guessing you're using a loop somewhere) or the actual percentage complete?, there is a difference.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
int row = 0;
int col = 0;
row = e.RowIndex;
col = e.ColumnIndex;
object val1 = dataGridView1[col, row].Value.ToString();
MessageBox.Show(val1.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
error: object reference not set to an instance of an object
i'm getting this error. Please tell me how to correct this.
I've created a cellcontentclick event to get the row and column index where the checkbox is checked now i want to get the particular column value at this rowindex. As i want to get the address column data corresponding to the row in which checkbox is checked.
Thanks in Advance
Cheers
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
Hi All,
I have been trying to figure out how to
-
- Read streaming data from a html code, not from a file, (i.e. .....)
- Cleanup some of the ugly code in that streaming data
- Display the tidy code on a new browser windows
Do i need to use binaryReader/Writer? Please advice
Any idea or sample to check out. Thanks in advance
modified on Saturday, July 12, 2008 3:32 AM
|
|
|
|
|
Any one can provide me any info?
|
|
|
|
|
Hello,
I'm writing application with very complex configuration (System.Configuration). I need to pass ConfigurationSection or ConfigurationElement inherited class object as a method argument, but method executes in separate AppDomain, since neither ConfigurationSection nor ConfigurationElement doesn't inherit from MarshalByRefObject classs I constantly get a SerializationException exception.
If I add SerializableAttribute to my configuration section it works, but I can't modify any variable.
What can I do ?
Thanks in advance.
|
|
|
|
|
Hi guys! is there anyone who knows how to retrieve photos from sharepoint 2007 using C#? Urgent, Thanks!!!
|
|
|
|
|
|
Use the System.Diagnostics namespace. It includes the Process object that lets you run external programs.
using System.Diagnostics;
...
...
Process p = new Process("notepad.exe");
p.Start();
It also includes methods such as WaitForExit() that tells your program to wait till the process it terminated, and also the 'StartInfo' that lets you set customized settings for running a program. Browse the namespace for more details.
|
|
|
|
|
|
|
can u tell me in brief
howw to use this
|
|
|
|
|
heyy thankss
btt its opening in different windows even after giving same parent as first arguemment
|
|
|
|
|
Hello Friends,
I am developing a windows application in which i have used a RichTextBox. I want that some data in RichTextBox comes in bold and some text in Regular size.
Please tell me how can i do that...
Thanks
|
|
|
|
|
You can use SelectionStart, SelectionLength and SelectionFont properties of RichTextBox class for that.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi D i x y.
Did you see this :
http://www.codeproject.com/KB/recipes/RtfConverter.aspx
The Freshman
|
|
|
|
|
Hi, I have a grid (4 rows x 5 columns). I need to sort grid by last column. But I want to trace what changes were made to row order. I need this info to:
1. Change row header's text 'cause it doesn't change automatically during sort.
2. Change the columns order, i.e. I have rows 1,2,3,4. After sorting I have 2,3,1,4. And I want my columns moved in that way: 2,3,1,4 (with DisplayedIndex property for example)
|
|
|
|
|
Hi,
Would anyone tell me how I can store HTML within XML ? Because, when I have < tag in XML, the XML gets screwed up. Also when attribute values have " character, XML gets error.
|
|
|
|