Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old February 28th, 2008, 06:10 PM
Authorized User
Join Date: Feb 2007
Location: , , USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help with these questions

Hello- Please help me with the following questions, if possible,
please also provide some explanations--thanks in advance:

1) Assuming that "valid connection string" is a valid connection string, what will be the output of the following code? If the code cannot compile, please state why.
    the same rules apply to this question as for the one above
    using(SqlConnection sqlConn = new SqlConnection("valid Connection string"))
        System.Diagnostics.Debug.WriteLine("Opening a connection");
        System.Diagnostics.Debug.WriteLine("Connection Opened");
        System.Diagnostics.Debug.WriteLine("Connection Closed");

    if(sqlConn == null)
        System.Diagnostics.Debug.WriteLine("Connection State is NULL");
        System.Diagnostics.Debug.WriteLine("Connection State:" + sqlConn.ConnectionState);

2)The following code needs to generate a string of 1000 alternating '+' and '-' characters
Rewrite this code to make it more efficient (Note: You can use different data types than the ones present)

string htmlOutput = string.Empty;
for(int itemIndex = 0; itemIndex < 1000; itemIndex++)
    if( itemIndex % 2 == 0)
        htmlOutput += "+";
        htmlOutput += "-";

3)Assuming that CustomException is defined, what will be the output of the following code?
    throw new CustomException("Something went wrong");
catch(Exception ex)
    System.Diagnostics.Debug.WriteLine("Generic Exception has been triggered");
catch(CustomException ex)
    System.Diagnostics.Debug.WriteLine("Custom Exception has been triggered");

4) What will be the difference in behavior between the lines marked 'a' and 'b' during runtime? (Assume that CustomClass is a defined class)

    object objClass = new object();

    CustomClass myClass1 = objClass as CustomClass; //a
    CustomClass myClass2 = (CustomClass)objClass; //b

5) Assuming you have the following class:

    public class MyClass
        public MyClass()

        public string DoNothing(string someParameter)

    How would you call the DoNothing function asynchronously and provide a callback?

6) What is the difference between a Monitor and a Semaphore?

7) Architectural Question: If you have pages that perform heavy DB or File I/O, what could be done to help increase the overall performance of the application? (Asp.net only! Assume all non asp.net factors have been optimized to the max)

8) What is the difference between the following 2 statements?

    throw new ApplicationException("None");
catch(Exception ex)
    throw ex;

    throw new ApplicationException("None");
catch(Exception ex)
9) What is the difference between a List and a LinkedList?

10) Assume that you retrieve a list of 1,000,000 Person objects from a database that contain the SocialSecurityID, First and Last name properties. Which collection class would you use to store and allow for quick lookup of Person objects based on the SocialSecurityID field?

Reply With Quote
  #2 (permalink)  
Old February 28th, 2008, 06:14 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,133
Thanks: 1
Thanked 189 Times in 188 Posts

No-one is going to do your homework for you.

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Interview Questions, C# Interview Questions, dotnetuncle .NET Framework 2.0 3 April 9th, 2015 07:43 AM
C++ questions jam93 C++ Programming 1 August 19th, 2007 10:39 PM
two questions reverand Excel VBA 2 December 5th, 2005 05:33 AM
C# questions zhenliu C# 1 April 15th, 2004 09:18 AM
questions anshul Javascript How-To 1 April 12th, 2004 07:29 AM

All times are GMT -4. The time now is 08:52 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.