|
hi
you must use arraylist;
do this:
you must define the multiplication yourself on the arraylist.
each elements of arraylist contains only one integer.
say
for( int i=1;i< 500;i++)
{
multiplay i in each elemnt of arrayList and add its more than 10 of element to next element such you do on paper.
}
you can calculate n! by this
|
|
|
|
|
hello
i am calcualting factorial and saving its value in double data type. But double can't calculate factorial of >170 .
Plz help me if u know how can i calculate factorial of above 200 or say 500 factorial.
Regards
aneela
|
|
|
|
|
|
leppie wrote:
Why on earth do you wanna calculate such huge numbers?
That's usual demonstration of difference between recursive vs. iterative algorithm in terms of speed.
(Iterative one is much faster in this case)
Hmm and practical use of 500! ? benchmarks maybe...
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
You might want to check-out the C# BigInteger Class[^] article here on CodeProject. That may help.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hello
Thank you so much for such a quick prompt. All of you are so nice and helping people.
Regards
asmyan
|
|
|
|
|
I was chagrinned that .NET doesn't have a BigInteger class, but this one by Chew Keong Tan looks good. I gave it a quick try with this:
public static BigInteger factorial( int n )
{
BigInteger result = new BigInteger(1);
for( int i = 1; i <= n; i++ )
result = result * i;
return result;
}
... And later, in Main():
Console.WriteLine("factorial of 170 = " + factorial(170) );
And it works just fine, giving:
7, 257, 415, 615, 307, 998, 967, 396, 728, 211, 129, 263, 114, 716, 991, 681, 296, 451, 376, 543, 577, 798, 900, 561, 843, 401, 706, 157, 852, 350, 749, 242, 617, 459, 511, 490, 991, 237, 838, 520, 776, 666, 022, 565, 442, 753, 025, 328, 900, 773, 207, 510, 902, 400, 430, 280, 058, 295, 603, 966, 612, 599, 658, 257, 104, 398, 558, 294, 257, 568, 966, 313, 439, 612, 262, 571, 094, 946, 806, 711, 205, 568, 880, 457, 193, 340, 212, 661, 452, 800, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000
At least it got the same number I calculated off the top of my head.
(I formatted with commas and spaces to prevent extreme horizontal scrolling in this post! (and no, I didn't insert them manually -- do you think I'm nuts?))
Matt Gerrans
|
|
|
|
|
Matt Gerrans wrote:
do you think I'm nuts?
You must be if you calculated that in your head!
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi sylvain2222
Code Url[http://www.codeproject.com/dotnet/PrintingFormReport.asp[^]]
I have some problem in using you code in C#. Please help
1: How to call datagrid control, List View, Tree View like these controls?
2: How to print date?
3: If I want to print some controls in a form like I want to print textbox, checkbox, datagrid but skip the labels or other controls?
4: Can we skip specifically some label or single label or any other control?
5: Can I skip Form Title for Printpreview?
6: I have some special user controls like gradient labels. Can I also take this kind of controls in printpreview?
I shell be very grateful if you tell me soon and in C#. Please
I am waiting for you quick response…
Muhammad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
You should post your questions on a specific article in the message board thread at the bottom of the article. Your question here will quickly be lost amongst all the other questions and the author may not see it posted here. If you post your question in the article thread, you question will be emailed to the author.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks For Inform me. But i would like to tell you that i have already post this on the message board of that article. But i post that problem on the main thread board i think may be some else use the in C# and hopefully he will help me.
Anyways i still need solution of this problem....
Muhammad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
|
If you have questions or comments about an article here on CodeProject you need to ask in the message board at the bottom of the article - that's what it's there for.
If you are new to C#, I suggest you read about the Visual C# Language[^] and browse over the table of contents for the Class Library[^].
There's many books about C# as well. You can find many Microsoft-approved books at http://www.microsoft.com/mspress[^], and many more on Amazon[^].
This forum is for specific questions regarding C#.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Is there any possibility to return windows form a remote application to client application, in distributed application environment. I tried with .NET Remoting (Hosting server in Windows Service and IIS) as well as through Web Service. But none of them worked.
|
|
|
|
|
Edit:
No, it's not. Even if it was, you'll end up displaying the form in the server process, not the client process - which I discovered not too long ago.
This is all totally in contradiction to what I had originally said. Whooops.
This space for rent!
My Blog
|
|
|
|
|
I have build a Win Application using C# that interact with an embedded Web Browser Control. I need to highlight text that user searches for in the loaded browser document. Kind of like the Windows Xp help center. When you look for something, the help article is loaded and the text you are searching for is highlighted.
Elie
|
|
|
|
|
Add a reference to the Microsoft.mshtml.dll assembly that should've been installed with VS.NET. If you don't see it in your list of references, then in the Add Reference dialog click the COM tab and find the "Microsoft HTML Object Library" and add that. VS.NET will automatically create an interop assembly (RCW, or Runtime Callable Wrapper) for you and reference that.
To begin, when your document is loaded cast AxWebBrowser.Document to IHTMLDocument2 (add the Microsoft.mshtml namespace to your using clauses, BTW). Now you have a reference to the HTML DOM. From there you'd do what you'd do in HTML to highlight text, only you're doing it using the actual interfaces instead of how you'd do it in JavaScript/JScript or VBScript. The script uses the HTML DOM - the very one you've referenced, so what you get is the same (and more so).
Do that, cast IHTMLDocument2.body to IHTMLBodyElement and call createTextRange to get an IHTMLTxtRange . With that keep calling findText until it returns false . Each time that string is found do something like this:
range.htmlText = @"<span style=""color:white;background-color:darkblue;"">" + range.htmlText + @"</span>";
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for your help. The documents that I load in the browser are xml files and are in Arabic (right to left). I have tried the method you described above. Eventhough it worked well, I had a little bit of formatting problems. I decided to search xml files themselves, and format the matching strings using xslt file.
Anyway, thank you for your help. It set me on the right track.
Elie
|
|
|
|
|
how to add it to richtextbox?
|
|
|
|
|
You can't. Both are controls, and the RichTextBox is not a container controls. You could always try to site (that is, manually position the LinkLabel control as the RichTextBox is scrolled) but that can be difficult.
A better question is why? Just set RichTextBox.DetectUrls to true . Whenever a URL using a recognized protocol scheme is entered into the text, it is a URL. Then add a handler for the RichTextBox.LinkClicked event and do what you would've done in a LinkLabel.LinkClicked event handler.
The protocols schemes that are automatically detected - from the Platform SDK - are:
http:
file:
mailto:
ftp:
https:
gopher:
nntp:
prospero:
telnet:
news:
wais:
outlook:
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi
i known that but my links are not url ,they are say a name such "X".
what should i do plz?
|
|
|
|
|
The Rich Edit common control - which the RichTextBox encapsulates - does not support extensible URL detection, unfortunately, but you can implement this yourself.
When the text changes scan behind the caret (get the SelectionStart property) and see if its text you want to recognize as a "URL". Use the SelectionColor and SelectionFont to highlight and underline the font.
If you want to use the same font style that the RichTextBox is using, use the Microsoft.Win32.RegistryKey class to read appropriate values from HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Settings.
Handle the Click event, get the SelectionStart again, determine which text was clicked and, if it's a "link", perform whatever action is appropriate.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The underlying RichEdit control has a way to mark an arbitrary character range as link, even if it's not starting with one of the recognized protocols.
Basically, you'll have to use interop to send the message EM_SETCHARFORMAT to the RichTextBox and specify CFE_LINK as effect.
The message and parameters are described on MSDN, you can look up the documentation there.
You might want to take a look at this article[^] (follow the section "Adding Formatting to the New Class") on how to set the character format in a RichTextBox. The code there can be easily modified to allow for setting the Link style as well.
I guess I'll write an article about this in the near future because this topic comes up from time to time...
Regards,
mav
|
|
|
|
|
Hi all,
In VC++, in CRichEditControl class have a method naming 'LineScroll'. This method is used to scroll HScroll to any line. Would you tell me method in C# that similar LineScroll method of CRichEditControl class in VC++.
Thank you very much,
|
|
|
|
|
You could implement a similar method using P/Invoke:
public class ExtendedRichTextBox : RichTextBox
{
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
IntPtr wParam, IntPtr lParam);
const uint EM_LINESCOLL 0x00B6;
public void ScrollToLine(int line)
{
IntPtr lParam = new IntPtr(line);
SendMessage(Handle, EM_LINESCOLL , IntPtr.Zero, lParam);
}
} This will not extend past the last line. Read in the Platform SDK about the EM_LINESCROLL message for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|