Briefly highlight the differences between imperative and declarative security as they pertain to code access security.

1 Answer

Answer :

Imperative security is implemented by calling methods of Permission objects in code at run time. Declarative security is configured by attaching attributes representing permissions to classes and methods. Imperative security allows a finer control over the point in execution where permissions are demanded, but declarative security is emitted into metadata, and required permissions can be discovered through the classes in the System.Reflection namespace. Additionally, you can request assembly-wide permissions using the Assembly (assembly) directive with declarative security.

Related questions

Description : Is the sentence don and rsquot walk on the clean floor with those dirty feet declarative imperative interrogative or exclamatory?

Last Answer : Feel Free to Answer

Description : Is this sentence a declarative interrogative imperative or exclamatory Have you ever been sent to the principal's office?

Last Answer : What is the answer ?

Description : Briefly summarize the similarities and differences between arrays and collections.

Last Answer : Arrays and collections allow you to manage groups of objects. You can access a particular object by index in both arrays and collections, and you can use For Each Next (foreach) syntax to iterate ... Collections namespace can grow or shrink dynamically, and items can be added or removed at run time.

Description : Briefly explain the difference between Public (public), Friend (internal), and Private (private) access levels as they apply to user-defined types and members.

Last Answer : In user-defined types, Public (public) classes can be instantiated by any element of the application. Friend (internal) classes can be instantiated only by members of the same assembly, and Private ( ... the same assembly, and Private (private) members can be accessed only from within the type. 

Description : Briefly contrast connected and disconnected data access in ADO.NET.

Last Answer : In ADO.NET, connected data access is available through the DataReader, which is a lightweight class designed to provide very fast and efficient data access. It is severely limited, however, in ... to update the database and keeping the connection open just long enough to execute those commands.

Description : Briefly describe the three types of user-developed controls and how they differ.

Last Answer : The three types of user-developed controls are inherited controls, user controls, and custom controls. An inherited control derives from a standard Windows Forms control and inherits the ... inherit only generic control functionality. All specific functionality must be implemented by the developer.

Description : Briefly describe how a class is similar to a structure. How are they different?

Last Answer : Both classes and structures can have members such as methods, properties, and fields, both use a constructor for initialization, and both inherit from System.Object. Both classes and structures can be ... are value types, and the memory that holds structure instances is allocated on the stack. 

Description : Briefly describe the five accessibility requirements of the Certified for Windows logo program.

Last Answer : The five requirements are o Support standard system settings. This requires your application to be able to conform to system settings for colors, fonts, and other UI elements. o Be ... information by sound alone. This requirement can be met by providing redundant means of conveying information.

Description : Briefly describe how to use the PrintDocument component to print a document. Discuss maintaining correct line spacing and multipage documents.

Last Answer : The PrintDocument class exposes the Print method, which raises the PrintPage event. Code to render printed items to the printer should be placed in the PrintPage event handler. The PrintPage event ... been printed, you must incorporate all logic for printing multiple pages into your event handler.

Description : What are the four major parts of a SQL SELECT statement? Briefly describe each one.

Last Answer : The four major parts of a SELECT statement are SELECT, FROM, WHERE, and ORDER BY. SELECT specifies the fields to be retrieved. FROM specifies the table from which the records are to be retrieved. WHERE ... the records to be retrieved, and ORDER BY allows you to specify a sort order for the records.

Description : Briefly describe an XmlDataDocument and how it relates to a DataSet.

Last Answer : An XmlDataDocument is an in-memory representation of data in a hierarchical XML format. Each XmlDataDocument is synchronized with a DataSet. Whenever changes are made to one object, the other is instantly updated. Thus, you can use the XmlDataDocument to perform XML manipulations on a DataSet.

Description : Briefly discuss the advantages and disadvantages of using typed DataSet objects.

Last Answer : Typed DataSet objects allow you to work with data that is represented as members of the .NET common type system. This allows your applications to be aware of the types of data returned in a DataSet and serves ... if you do not know the structure of your data, and can be used with any data source. 

Description : Briefly explain encapsulation and why it is important in object-oriented - programming.

Last Answer : Encapsulation is the principle that all of the data and functionality required by an object be contained by that object. This allows objects to exist as independent, interchangeable units of functionality without maintaining dependencies on other units of code.

Description : What are the two kinds of multidimensional arrays? Briefly describe each.

Last Answer : Multidimensional arrays can be either rectangular arrays or jagged arrays. A rectangular array can be thought of as a table, where each row has the same number of columns. Rectangular arrays with ... dimensional jagged array is like a table where each row might have a different number of columns.

Description : Briefly explain how to convert a string representation of a number to a numeric type, such as an Integer or a Double.

Last Answer : All numeric data types have a Parse method that accepts a string parameter and returns the value represented by that string cast to the appropriate data type. You can use the Parse method of each data type to convert strings to that type.

Description : Briefly describe what members are, and list the four types of members.

Last Answer : Members are the parts of a class or a structure that hold data or implement functionality. The primary member types are fields, properties, methods, and events.

Description : Briefly describe how garbage collection works.

Last Answer : The garbage collector is a thread that runs in the background of managed .NET applications. It constantly traces the reference tree and attempts to find objects that are no longer referenced. When a nonreferenced object is found, its memory is reclaimed for later use.

Description : Briefly explain what is meant by a reference type and a value type.

Last Answer : A value type holds all of the data represented by the variable within the variable itself. A reference type contains a reference to a memory address that holds the data instead of the actual data itself. 

Description : Briefly describe the major components of the .NET Framework and describe what each component does.

Last Answer : The .NET Framework consists of two primary parts: the common language runtime, which manages application execution, enforces type safety, and manages memory reclamation, and the .NET base class library, which consists of thousands of predeveloped classes that can be used to build applications.

Description : List the differences in C# 2.0. 

Last Answer : • Generics • Iterators • Partial class definitions • Nullable Types • Anonymous methods • :: operator • Static classes static class members • Extern keyword • Accessor accessibility • Covariance and Contravariance • Fixed size buffers • Fixed assemblies • #pragma warning

Description : Define what are the differences between static, public and void in C#?

Last Answer : 1. Static classes/methods/variables are accessible throughout the application without creating an instance. The compiler will store the method address as an entry point. 2. Public methods or variables are accessible ... 3. The void is used for the methods to indicate it will not return any value.

Description : List out the differences between Array and ArrayList in C#?

Last Answer : Array stores the values or elements of the same data type but ArrayList stores values of different data types. Arrays will use the fixed length but ArrayList does not use fixed length like an array.

Description : Can different assemblies share internal access? 

Last Answer : No

Description : Can properties have an access modifier?

Last Answer : Yes

Description : Can you use access modifiers with destructors? 

Last Answer : No

Description : Can events have access to modifiers?

Last Answer : Yes, you can have access to modifiers in events. You can have events with the protected keyword, which will be accessible only to inherited classes. You can have private events only for objects in that class.

Description : Describe how to use code to retrieve resources at run time.

Last Answer : You must first create an instance of the ResourceManager class that is associated with the assembly that contains the desired resource. You can then use the GetString method to retrieve string resources or the GetObject method to retrieve object resources.

Description : Explain how to convert data in legacy code page formats to the Unicode format.

Last Answer : You can use the Encoding.Convert method to convert data between encoding types. This method requires instances of both encoding types and an array of bytes that represents the data to be converted. ... GetBytes method and can convert an array of bytes back to chars with the Encoding.GetChars method.

Description : Describe how to retrieve the ASCII key code from a keystroke. How would you retrieve key combinations for non-ASCII keys?

Last Answer : Keystrokes can be intercepted by handling the KeyPress and KeyDown events. Both of these events relay information to their handling methods in the form of their EventArgs. The KeyPressEventArgs, ... you would handle the KeyDown event and use the properties exposed by the KeyEventArgs instance.

Description : What is unsafe code?

Last Answer : Unsafe code bypasses type safety and memory management.  

Description : Write code to use threading and the lock keyword. 

Last Answer : using System; using System.Threading; namespace ConsoleApplication4 { class Class1 { [STAThread] static void Main(string[] args) { ThreadClass tc1 = new ThreadClass(1); ThreadClass tc2 = new ThreadClass( ... Console.WriteLine(threadNumber + " working"); Thread.Sleep(1000); } } } } }

Description : Write code to define and use your own custom attribute.

Last Answer : (From MSDN) // cs_attributes_retr.cs using System; [AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple=true)] public class Author : Attribute { public Author(string name) { this.name ... double version; string name; public string GetName() { return name; } }

Description : Write some code to declare and use properties.

Last Answer : // instance public string InstancePr { get { return a; } set { a = value; } } //read-only static public static int ClassPr { get { return b; } }

Description : Write some code to implement an indexer.

Last Answer : using System; namespace Console1 { class Class1 { static void Main(string[] args) { MyIndexableClass m = new MyIndexableClass(); Console.WriteLine(m[0]); Console.WriteLine(m[1]); Console.WriteLine(m[2]); Console. ... get { return myData[i]; } set { myData[i] = value; } } } }

Description : Write some code that uses an ArrayList.

Last Answer : ArrayList list = new ArrayList(); list.Add("Hello"); list.Add("World");

Description : Write some code to implement a jagged array. 

Last Answer : // Declare the array of two elements: int[][] myArray = new int[2][]; // Initialize the elements: myArray[0] = new int[5] {1,3,5,7,9}; myArray[1] = new int[4] {2,4,6,8};

Description : Write some code to implement a multidimensional array.

Last Answer : int[,] b = {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}}; 

Description : Write some code for a custom collection class.

Last Answer : using System; using System.Collections; public class Items : IEnumerable { private string[] contents; public Items(string[] contents) { this.contents = contents; } public IEnumerator GetEnumerator() { ... (string item in items) { Console.WriteLine(item); } Console.ReadLine(); } }

Description : Write some code that declares an array on ints, assigns the values: 0,1,2,5,7,8,11 to that array and use a foreach to do something with those values.

Last Answer : int x = 0, y = 0; int[] arr = new int [] {0,1,2}; foreach (int i in arr) { if (i%2 == 0) x++; else y++; }

Description : Write some code for do… while.

Last Answer : int x; int y = 0; do { x = y++; Console.WriteLine(x); } while(y < 5);

Description : Write some code for a while loop. 

Last Answer : int n = 1; while (n < 6) { Console.WriteLine("Current value of n is {0}", n); n++; }

Description : Write some code for a for loop 

Last Answer : for (int i = 1; i <= 5; i++) Console.WriteLine(i);

Description : Write some if… else if… code.

Last Answer : int n=4; if (n==1)  Console.WriteLine("n=1"); else if (n==2) Console.WriteLine("n=2"); else if (n==3) Console.WriteLine("n=3"); else Console.WriteLine("n>3");

Description : Write some try…catch…finally code.

Last Answer : // try-catch-finally using System; public class TCFClass { public static void Main () { try { throw new NullReferenceException(); } catch(NullReferenceException e) { Console.WriteLine("{0} exception 1 ... ("exception 2."); } finally { Console.WriteLine("finally block."); } } }

Description : Write some code to overload an operator. 

Last Answer : class TempleCompare { public int templeCompareID; public int templeValue; public static bool operator == (TempleCompare x, TempleCompare y) { return (x.templeValue == y.templeValue); } ... templeValue); } public override int GetHashCode() { return templeCompareID; } }

Description : Write code for a case statement. 

Last Answer : switch (n) { case 1: x=1; break; case 2: x=2; break; default: goto case 1; }

Description : Write code for an enumeration. 

Last Answer : public enum animals {Dog=1,Cat,Bear}; 

Description : Write some code to box and unbox a value type. 

Last Answer : // Boxing int i = 4; object o = i; // Unboxing i = (int) o;

Description : Write some code to use a delegate. 

Last Answer : Member function with a parameter using System; namespace Console1 { class Class1 { delegate void myDelegate(int parameter1); static void Main(string[] args) { MyClass myInstance = new ... void AMethod(int param1) { Console.WriteLine(param1); } } }

Description : Write code to show how a method can accept a varying number of parameters.

Last Answer : using System; namespace Console1 { class Class1 { static void Main(string[] args) { ParamsMethod(1,"example"); ParamsMethod(1,2,3,4); Console.ReadLine(); } static void ... o in list) { Console.WriteLine(o.ToString()); } } } }