|
how to add two integers using c# language
|
|
|
|
|
int a = 2;
int b = 3;
int c = a + b; or simply
int c = 2 + 3;
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
What do you mean? Can you be more clear at what you exactly want?
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
If you're asking questions on this sort of level, the answer is to abandon asking questions, buy a book and work through it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I wanted to mock him, but I thought that people might think I was picking on the weak and defenseless, but what the hey - I feel some mocking bubbling up.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I was offering serious advice. If he doesn't know how to add two integers, who knows what he'll ask next ? It's quicker for him to work through a book, at that level.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Wrong forum - this should be on the Mathematics and algorithms forum.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I don't think you'll get thanked for that over on the M&A forum.
|
|
|
|
|
Colin Angus Mackay wrote: I don't think you'll get thanked for that over on the M&A forum.
At least somebody would be using it then. It's a great forum with not a lot being put on it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
It seems that you don't need this message board, you need a book, or listen in class.
|
|
|
|
|
public long Sum(int a, int b)<br />
{ <br />
long f = 0;<br />
for (int i = 0; i < a; i++)<br />
{if (f % 2 == 0)<br />
{f ^= 1;}<br />
else<br />
{int k = 0;<br />
long e = f;<br />
while (e % 2 == 1)<br />
{e = e >> 1;<br />
k++;}<br />
int l = 1;<br />
for (int j = 0; j < k; j++)<br />
{l = l << 1;<br />
l ^= 1;}<br />
f ^= l;}}<br />
for (int i = 0; i < b; i++)<br />
{if (f % 2 == 0)<br />
{f ^= 1;}<br />
else<br />
{int h = 0;<br />
long g = f;<br />
while (g % 2 == 1)<br />
{g = g >> 1;<br />
h++;}<br />
int l = 1;<br />
for (int j = 0; j < h; j++)<br />
{l = l << 1;<br />
l ^= 1;}<br />
f ^= l;}}<br />
return f;<br />
}
Usage example: Sum(3,4). Will return 7.
|
|
|
|
|
Any NUnit tests available ?
Luc Pattyn
|
|
|
|
|
Sorry no. Wrote this in about 10-15 minutes. Tested it with two numbers and it worked. Good enough for me. I didn't want to spend more time coding this, as I think I already took this joke a bit far (though it would've been nice to write some code without using the increment operators )
BTW, refactoring in VS2005 is still one of my favorite features. Sure did the trick on those pesky, descriptive variable names 
|
|
|
|
|
*Family Feud voice* Good answer...Good answer lol
|
|
|
|
|
That cheered my day up no end .. thanks.
PS. You should write a book on the subject - any subject will do
Glen Harvy
|
|
|
|
|
how to convert an exisisting project
(windows application) exe file into an dll
thanking u
|
|
|
|
|
Change the output type in the project settings from windows application to class library.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello!
This is my first post here ...
I've written this configuration file to run in my .NET 2.0 application:
(The post isn't showing the XML, so I'll put an image)
http://img213.imageshack.us/img213/3071/configgr7.gif
... and also this SectionHandler class:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Configuration;<br />
using System.Xml;<br />
<br />
namespace Prototipo<br />
{<br />
public class PublisherInfo<br />
{<br />
private String regEx;<br />
private String destinationFilePath;<br />
<br />
public PublisherInfo(String r, String f)<br />
{<br />
regEx = r;<br />
destinationFilePath = f;<br />
}<br />
}<br />
<br />
class SectionHandler : IConfigurationSectionHandler<br />
{<br />
public object Create(object parent, object context, XmlNode section)<br />
{<br />
string r = section["regEx"].InnerText;<br />
string f = section["destinationFilePath"].InnerText;<br />
return new PublisherInfo(r, f);<br />
}<br />
}<br />
}<br />
But when I try to get the information from that file I get exception, saying that there was an error while trying to initialize the configuration system, and an innerexception saying that a section
is repeated (I suppose it's the "publisher" sections).
Isn't there any way to process this file without getting errors? If not, how would you re-write the configuration file so that I don't get any error?
Thanks a lot!! t any error?
Thanks a lot!!
|
|
|
|
|
Hi,
i need to make a call to a webservice and in addition abort this call if the response exeeds some specific time. I want to do this because i have to provide a method to the user which returns a value from a webservice through this method not through some callbackevent. This way i decided that it would be a good way to wrap the call to the service in a method, wait for the response (or a specific time, whatever comes first) and return the value to the user.
What i have done so far is that i make a call to XXXAsync, hooked up to the return event and set a flag that the webservice responded. In the method called by the user a wait for this flag to be set to true or a specific time, but somehow the webservice return event never fires. If i remove the waiting loop everything works fine.
Here is some sample code of the method i want to wrapt the webservice call in:
<br />
public float FaceImageQuality(Image faceImage)<br />
{<br />
this.retrievedFaceQuality = -10;<br />
this.faceQualityCheckReturned = false;<br />
fvws.FaceQualityAsync(ImageToByteArr(faceImage));<br />
int localCounter = 0;<br />
while (localCounter < this.maxWaitTime || this.faceQualityCheckReturned)<br />
{<br />
localCounter++;<br />
Thread.Sleep(100);<br />
}<br />
if (!this.faceQualityCheckReturned && localCounter >= this.maxWaitTime)<br />
throw new Exception(String.Format(this.webServiceDidNotResponded, (this.maxWaitTime * 10), "FaceImageQuality"));<br />
return this.retrievedFaceQuality;<br />
}<br />
<br />
private void fvws_FaceQualityCompleted(object sender, FaceValidationClass.FaceValidationWebService.FaceQualityCompletedEventArgs e)<br />
{<br />
this.retrievedFaceQuality = e.Result;<br />
this.faceQualityCheckReturned = true;<br />
}<br />
When i remove the Thread.Sleep call and the loop off the code the event fires, but only after the method is left.
Does anyone knows a way to solve this?
Best regards
Jens
|
|
|
|
|
Hi,
Can anybody help me out to get the HTML source of webpade in C#? Right now thru below code I am getting the inner code but that is not whole source which I get when I do 'view source' on webpage....
.
.
.
ibrowser = (IWebBrowser2)pDisp;
HTMLDocument idoc = (HTMLDocument)ibrowser.Document;
innerHTML = idoc.documentElement.innerHTML;
......
plz do reply asap.
thanks n regards,
Supriya
|
|
|
|
|
One way to get the page's entire content is to use this[^] class. The Content property holds the HTML source.
/ravi
|
|
|
|
|
hey that prob got solved actually, thx anyway!
Now I want to change the text on webpage, U can say I want to highlight particular word on webpage n display that page again.
Now I m doing below thing,
.
.
String str = internalBrowser.Document.Body.InnerText.Replace("MSN","mSn!");
internalBrowser.Document.Body.InnerText = str;
.....
but when page is displayed just the text gets displayed n not the exact page or Images n all...
I have one more option to parse internalBrowser.Document.Body.InnerHTML n change the word n append tag for highlighting the particular word... is it right or is there any other way????
thx
Supriya Tonape
|
|
|
|
|
Hi
Just want to hear whether C# can be successfully used to develop games in general and particularly multiplayer games? Or else what would be the preferred language for these higher end games?
Thanks.
Kobus
|
|
|
|
|
While games (even pretty complex ones) can be created with C#, the games you are used to playing were probably written using C++ (and possibly a few other languages)
|
|
|
|
|
It can (normally using Managed DirectX), but games are more traditionally written using C/C++.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|