MCSD Certification Toolkit (Exam 70-483).pdf

MCSD Certification Toolkit (Exam 70-483).pdf - MCSD...

This preview shows page 1 - 3 out of 16 pages.

1. How can you generate dynamic code in C#? CodeDOM Expression Trees 2. How can you specify CAS in code? 2 methods Declarative CAS -Uses attributes to apply security information to your code Example [FileIOPermission(SecurityAction.Demand, AllLocalFiles = FileIOPermissionAccess.Read)] Imperative CAS -Ask permission in the code Example FileIOPermission f = new FileIOPermission(PermissionState.None); f.AllLocalFiles = FileIOPermissionAccess.Read; try { f.Demand(); } catch (SecurityException s) { Console.WriteLine(s.Message); } 3. How can you use one enum to set multiple combinations of values? Use the Flags attribute. Example [Flags] enum Days { Monday = 0x2, Tuesday = 0x4, Wendesday = 0x8 .... } Days example = Days.Monday | Days.Tuesday; 4. How does a C# program check if an attribute has been applied? Use the Attribute class, from which all other attributes inherit. Example [Serializable] class Person { } if (Attribute.IsDefined(typeof(Person), typeof(SerializableAttribute))) { } 5. How does a SqlDataReader handle results from multiple batched SQL Statements? The SqlDataReader contains mutiple result sets. You can advance to the next result set by calling NextResult or NextResultAsync on the SqlDataReader object. 6. How does a Task signal to outside users that it has been cancelled? It can use a CancellationToken to throw a OperationCanceledException Example token.ThrowIfCancellationRequested(); 7. How does CAS determine if a method has the required permissions? It walks the call stack to make sure that EVERY method on the call stack has the appropriate permissions. This way a less-trusted method cannot call some restricted code through a highly trusted method. 8. How does the .Net framework handle exceptions in a parallel query? It aggregates all exceptions in one AggregateException object. This exception exposes a list of all exceptions that have happened during a parallel execution. try { // Parallel query } catch (AggregateException e) { Console.WriteLine(e.InnerExceptions.Count); } 9. How do you access a Drive in C#? Use the DriveInfo class. Example DriveInfo[] drivesInfo = DriveInfo.GetDrives(); driveInfo.IsReady driveInfo.Name driveInfo.DriveType driveInfo.AvailableFreeSpace 10. How do you allow multiple instances of an attribute to be applied to an element? Use the AllowMultiple parameter to the AttributeUsage attribute. Example [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 11. How do you avoid deadlocks in your code? Make sure that locks are requested in the same order. Don't lock on the "this" object. Don't lock on a string. 12. How do you build a connection string dynamically? Use the DbConnectionStringBuilder classes. Example var sqlConnectionStringBuilder new SqlConnectionStringBuilder(); sqlConnectionStringBuilder.DataSource = @"(localdb)\v11.0"; sqlConnectionStringBuilder.InitialCatalog = "ProgrammingInCSharp"; string connectionString = sqlConnectionStringBuilder.ToString(); MCSD Certification Toolkit (Exam 70-483): Programming in C# by @SHANEBREWER Study online at
Image of page 1

Subscribe to view the full document.

Image of page 2
Image of page 3

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern