|
But this is not a static string concatenation because Convert.ToChar(34).ToString() isn't a constant, but a method call.
Only string concatenations that don't cause a compile error in const declarations are optimized by the compiler.
E.g.
const string name = "Bob";
const string test = "Hello " + name; // valid, concatenation happens at compile time
const string test2 = "Hello" + Convert.ToChar(32).ToString() + "Bob"; // invalid
|
|
|
|
|
|
He most probably didn't understand what he was doing, that's sad.
Je vous salue du Québec !
|
|
|
|
|
Placing an "@" does not produce any error for line break.
e.g. the following code would produce an error.
string x = "Blah blah blah"
+ Convert.Tochar(37) .ToString();
But the following would not
string x = @"Blah blah blah"
+ Convert.Tochar(37) .ToString();
(I am writing this without testing. So feel free to let me know if I am wrong.)
|
|
|
|
|
as an assignment, i asked for a program that we've all been through, a function that returns weather or not a given number is prime.
in one case, i was given the following :
if(num== 1 || num== 2 || num== 3 || num== 5 || num== 7 || num== 11 || num== 13 || num== 17 || num== 19 || num== 23 || num== 29 || num== 31 || num== 37 || num== 41 || num== 43 || num== 47 || num== 53 || num== 59 || num== 61 || num== 67 || num== 71 || num== 73 || num== 79 || num== 83 || num== 89 || num== 97 || num== 101 || num== 103 || num== 107 || num== 109 || num== 113)
{
return true;
}
else
{
return false;
}
when i asked him why he stopped at 113
(since it was the only thing i thought of asking) he said, in a tired voice,
"I couldn't think of any more numbers"
do you, or do you not feel sorry for him?
|
|
|
|
|
|
well then.
and i felt sorry for him having to find them on his own.
well observed!
|
|
|
|
|
- Pascal - wrote: wikipedia stops at 113 too
13 is considered bad unlucky number. Is 113 fall under this category also?
|
|
|
|
|
Interesting how many unproved conjectures there are.
Kevin
|
|
|
|
|
That would be one heck of a long list if they (the original coder or Wikipedia) attempted listing all the primes
Rob G
|
|
|
|
|
And, in addition to being very limited in the range of input values, the result isn't correct, either.
<SmartassMode>
1 is not a prime number, by definition.
</SmartassMode>
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
True, but that did not worry me.
|
|
|
|
|
mav.northwind wrote: 1 is not a prime number, by definition.
It is qualified as Unique Number right?
|
|
|
|
|
|
dbrenth wrote: The first 10000 prime numbers[^]
And any of the following things would have happened for sure:
1) Typing the if-else clause for 10000 numbers, he would broken the keyboard.
2) Typing the if-else clause for 10000 numbers, he would have broken down and ambulance should have been requested.
It is an unnecessary headache, at least in this case right?
|
|
|
|
|
Ask him to write a function that returns weather or not a given number is even
|
|
|
|
|
Well funny you should mention that, since it was asked previously.
Amazingly enough, most knew the *hidden* patterns of even numbers.
Or they heard me say modulus, between all the words that sent them to sleep.
|
|
|
|
|
Giorgi Dalakishvili wrote: Ask him to write a function that returns weather or not a given number is even
And for sure, the developer would written the code which would have thrown System.StackOverFlowException
|
|
|
|
|
How about a function that returns whether a number is an integer?
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
|
I really feel sorry for him...
I hope u might not have scold that poor guy
Regards
Anil
|
|
|
|
|
Nah, since for most of their test data it returned good results.
|
|
|
|
|
Waaaay back in college, in my first Pascal class, we were assigned the task of writing a program to perform the "Sieve of Eratosthenes"... but the assignment quoted a formula to use... which was faulty (of course). I don't know what the other students did, but I headed to the library.
If I ever teach (and I'd like to) I would assign the problem with extra credit to whomever builds the largest sieve. Wouldn't this be a good Friday programming quiz?
|
|
|
|
|
PIEBALDconsult wrote: Wouldn't this be a good Friday programming quiz?
I miss those.
I leave my office a bit early on Friday evenings and don't get to see the Friday quizzes because they're posted later in the day. (I don't have a computer at home.)
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
He does not need any computer to find prime numbers
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|