|
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");
sqlConn.Open();
System.Diagnostics.Debug.WriteLine("Connection Opened");
sqlConn.Close();
System.Diagnostics.Debug.WriteLine("Connection Closed");
}
if(sqlConn == null)
System.Diagnostics.Debug.WriteLine("Connection State is NULL");
else
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 += "+";
else
htmlOutput += "-";
}
3)Assuming that CustomException is defined, what will be the output of the following code?
try
{
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)
{
System.Diagnostics.Debug.WriteLine(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?
try
{
throw new ApplicationException("None");
}
catch(Exception ex)
{
throw ex;
}
try
{
throw new ApplicationException("None");
}
catch(Exception ex)
{
throw;}
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?
A.Asif
A.Asif
|
|
|
|
|
Cross posting does not help get answers, it just annoys everyone.
only two letters away from being an asset
|
|
|
|
|
Like this was not annoying to start with ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
What on earth posesses you to think that we should do your test for you?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Do your own damn work.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello All,
I have created an application which shuttles messages via TCP/IP using C# and the System.Net class.
The application currently has a form which just displays information about the connection and the message.
I would like to recreate the application as a service but I am too much of a novice to know where to go. Can anyone of you give me a hint as to where I could find information on how I would go about this.
Any assistance will be greatly appreciated.
Thanks
|
|
|
|
|
Search the CodeProject site. There are plenty of articles are doing this.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Imho, you're much better off using WCF to do this. You can embed the WCF service host in a WinForms/console app or a Windows service with absolutely to changes.
/ravi
|
|
|
|
|
One way to do this is to create a project of WindowsService type and write your Main method code in the OnStart event
and just copy paste rest of your code .
|
|
|
|
|
Hi,
I'm attempting to access the streams within an OLE container file. It is actually a linked OLE object (which is created by inserting an object as Linked OLE). I'm assuming it's an OLE object itself.
So, what APIs can I use to view these streams? Is there a native C# one (can't find any details about it on the net) or perhaps a C DLL one that I can link directly to? I've done something similar (linking to a DLL) with some other code I've done.
Any suggestions on what I can use, or a link to the MS documentation for that API?
I'd appreciate your comments,
Thanks
Dave Smith
|
|
|
|
|
I need to display form for 5 seconds. I have following code,
this.show();
int ret1 = 0;
int ret2 = 0;
ret1 = Configure1();
ret2 = CreateLogin();
System.Threading.Thread.Sleep(5000);
this.Close();
The form displays but it doesn't display the label on the form. Is there any other way to achieve the same?
|
|
|
|
|
harsha1305,
Label?, What label. In the code you pasted you display something - guessing a form - and then get to int's, tell the thread to sleep and close the form.
If you create the label in either Configure1(); or CreateLogin(); then you need to paste that code.
Regards,
Gareth.
|
|
|
|
|
Label is the control on the form.
|
|
|
|
|
you havent shown any code initializing a label.
maybe you just need to call InitializeComponents()?
|
|
|
|
|
Um you can't use Show,Sleep, and finally close in sequence and expect to get any UI behavior. Use a Timer rather than sleep and put the close in the timer event handler.
led mike
|
|
|
|
|
Can you send me sample code for timer for 5 seconds? I just want it to display the form for 5 seconds before closing.
|
|
|
|
|
I don't want to offend you but if you plan on being a capable software developer you need to learn to read documentation and how to find things like that for yourself. It is very likely that the documentation for the Timer class on MSDN has example code.
led mike
|
|
|
|
|
Hi,
I strongly advise against it in general, but here is a good opportunity to use
Application.DoEvents(); just in front of the Sleep.
However it is always better to use threading, since your Sleep will put the GUI interaction
out of service for 5 seconds no matter what.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
How can I create MacNotebook like menus if you have seen in C#. Thanks
|
|
|
|
|
Can you give some examples to the ones you've seen in C#?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I think i didn't clarify my point enough. Yesterday,I was using Mac OS and i liked their Operating System menus at the bottom of screen like how we have in Windows (Start) button. When I hover over an itme that particular item size gets bigger and i liked that transaction. So I am wondering how can I create this effect in my my C#
Thanksprogram
|
|
|
|
|
I like the way that works, too. Only thing I can think of is custom control for a tool that catches the MouseOver event for the individual icons to enlarge.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
If you download and register Visual C# Express 2008, you can get DevComponent's BubbleBar that does exactly this.
|
|
|
|
|
|
Port your C# application to the MacNotebook through MONO.
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios[ ^]
|
|
|
|