Click here to Skip to main content
16,008,075 members
Home / Discussions / C#
   

C#

 
QuestionBadImageFormatException while calling DLL in C# winx64 system? Why it gives error? Pin
sharp_k20-May-08 7:39
sharp_k20-May-08 7:39 
Questionhow to pass value of one page to another Pin
salil_k_singh20-May-08 6:21
salil_k_singh20-May-08 6:21 
AnswerRe: how to pass value of one page to another Pin
User 665820-May-08 6:43
User 665820-May-08 6:43 
AnswerRe: how to pass value of one page to another Pin
Gareth H20-May-08 7:12
Gareth H20-May-08 7:12 
QuestionDataSet merge method usage question. Pin
oscarderooij20-May-08 5:44
oscarderooij20-May-08 5:44 
AnswerRe: DataSet merge method usage question. Pin
topcatalpha20-May-08 21:27
topcatalpha20-May-08 21:27 
GeneralRe: DataSet merge method usage question. Pin
oscarderooij21-May-08 7:35
oscarderooij21-May-08 7:35 
QuestionC# Programming Challenge - By Reelix Pin
Reelix20-May-08 5:03
Reelix20-May-08 5:03 
Feel up for a challenge? Smile | :)

This isn't homework (Don't worry :p)

Was doing some coding optimisations, when I thought up the following challenge:

Code:

static void Main(string[] args)
        {
            Stopwatch sw1 = new Stopwatch();
            sw1.Start();
            string shortString = "1234567890";
            string largeString = "";
            for (int j = 0; j < 50000; j++)
            {
                largeString += shortString;
            }
            // Touch Nothing Below Here
            if (largeString.Length == 500000)
            {
                Console.WriteLine("Pass 1");
            }
            else
            {
                Console.WriteLine("Fail 1");
            }
            if (sw1.ElapsedMilliseconds < 10000)
            {
                Console.WriteLine("Pass 2");
            }
            else
            {
                Console.WriteLine("Fail 2 - " + sw1.ElapsedMilliseconds);
            }
            Console.ReadLine();
        }


Challenge:

Change ANY 2 lines of code ABOVE the
// Touch Nothing Below Here


code line to display ONLY the following output

Pass 1
Pass 2

As it stands, this code snippet displays (On my PC):

Pass 1
Fail 2 - 38614

Hint: The speed of your computer (Should Be) Irrelevant...
Optimised, it took 211ms on my PC (Which is ALOT less than 10000)


Good Luck Smile | :)

-= Reelix =-

AnswerRe: C# Programming Challenge - By Reelix [modified] Pin
originSH20-May-08 5:33
originSH20-May-08 5:33 
GeneralRe: C# Programming Challenge - By Reelix Pin
ssclaire20-May-08 6:35
ssclaire20-May-08 6:35 
GeneralRe: C# Programming Challenge - By Reelix Pin
User 665820-May-08 6:40
User 665820-May-08 6:40 
GeneralRe: C# Programming Challenge - By Reelix Pin
Guffa20-May-08 9:17
Guffa20-May-08 9:17 
GeneralRe: C# Programming Challenge - By Reelix Pin
Reelix20-May-08 9:10
Reelix20-May-08 9:10 
AnswerRe: C# Programming Challenge - By Reelix Pin
geekfromindia20-May-08 5:51
geekfromindia20-May-08 5:51 
GeneralRe: C# Programming Challenge - By Reelix Pin
Reelix20-May-08 9:05
Reelix20-May-08 9:05 
AnswerRe: C# Programming Challenge - By Reelix Pin
geekfromindia20-May-08 5:56
geekfromindia20-May-08 5:56 
AnswerRe: C# Programming Challenge - By Reelix [modified] Pin
User 665820-May-08 6:09
User 665820-May-08 6:09 
GeneralRe: C# Programming Challenge - By Reelix Pin
Reelix20-May-08 9:12
Reelix20-May-08 9:12 
AnswerToo easy Pin
Guffa20-May-08 8:01
Guffa20-May-08 8:01 
GeneralRe: Too easy Pin
Reelix20-May-08 9:17
Reelix20-May-08 9:17 
GeneralRe: Too easy Pin
Guffa20-May-08 9:21
Guffa20-May-08 9:21 
GeneralRe: Too easy Pin
Reelix20-May-08 19:58
Reelix20-May-08 19:58 
GeneralRe: Too easy Pin
Guffa21-May-08 6:00
Guffa21-May-08 6:00 
GeneralRe: Too easy Pin
The Nightcoder21-May-08 14:08
The Nightcoder21-May-08 14:08 
AnswerRe: C# Programming Challenge - By Reelix Pin
#realJSOP20-May-08 10:35
professional#realJSOP20-May-08 10:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.