Simple statement

  • Hi ,

         Can somebody help me on this?

     

    Consider the following fragment of C# code:

     

    string[] s = new string[]{"donald", "Adrian", "Douglas", "adam"};

    Array.Sort(s);

    for (int i = 0; i < s.Length; i++)

           Console.WriteLine(s);

     

    What will be the output here? 

  • just create a c# project and paste the code; no need to ask the question here.

    if it's not obvious, it's going to sort the array and print them line by line: adam/Adrian/donald/Douglas

    results form c#:

    'DefaultDomain': Loaded 'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.

    'WindowsApplication1': Loaded 'C:\Documents and Settings\lizaguirre\Desktop\ExcelExport\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.exe', Symbols loaded.

    'WindowsApplication1.exe': Loaded 'c:\winnt\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.

    'WindowsApplication1.exe': Loaded 'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.

    'WindowsApplication1.exe': Loaded 'c:\winnt\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.

    adam

    Adrian

    donald

    Douglas

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply