C# Interview Questions and Answers (958) - Page 3

Write a single line of code to create a text file and write contents into it.

Use following code

System.IO.File.WriteAllText(@"c:\MyTextFile.txt", "MyContents");
What is the best way to add items from an Array into ArrayList?

Use AddRange method of the ArrayList.

 string[] arr = new string[] { "ram", "shyam", "mohan" };

ArrayList arrList = new ArrayList();
arrList.AddRange(arr);

Which of the following is NOT Value type variable?

NOTE: This is objective type question, Please click question title for correct answer.
What is the correct order for Catch clauses when handling different exception types?

NOTE: This is objective type question, Please click question title for correct answer.
Why should you close and dispose of resources in a Finally block instead of a Catch block?

NOTE: This is objective type question, Please click question title for correct answer.
When should you use the StringBuilder class instead of the String class?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following statements are false?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following are not examples of built-in generic types?

NOTE: This is objective type question, Please click question title for correct answer.
You are creating a generic class, and you need to dispose of the generic objects. How can you do this?

NOTE: This is objective type question, Please click question title for correct answer.
Why should boxing be avoided?

NOTE: This is objective type question, Please click question title for correct answer.
Structures inherit ToString from System.Object. Why would someone override that method within a structure?

NOTE: This is objective type question, Please click question title for correct answer.
If there is no valid conversion between two types, what should you do when implementing the IConvertible interface?

NOTE: This is objective type question, Please click question title for correct answer.
With strict conversions enabled, which of the following would allow an implicit conversion?

NOTE: This is objective type question, Please click question title for correct answer.
Which are NOT acceptable ways to open a file for writing?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following are types of changes that can be detected by the File-SystemWatcher?

NOTE: This is objective type question, Please click question title for correct answer.
Which methods of the FileStream class doesn't affect the Position property?

NOTE: This is objective type question, Please click question title for correct answer.
How do you not force changes in a StreamWriter to be sent to the stream it is writing to?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories