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

1 Answer

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.

Related questions

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 : Explain how to retrieve information from the configuration file at run time. How would you store information in the configuration file at design time?

Last Answer : You must first create an instance of AppSettingsReader to read the configuration file. You can then call the GetValue method to read values represented in the configuration file. To add configuration ... used to retrieve the entry. The value can be changed between executions of the application.

Description : Describe in general terms how to add a control to a form at run time.

Last Answer : You must first declare and instantiate a new instance of the control. Then, you must add the control to the form�s Controls collection. Once the control has been added to the Controls collection, you must manually set properties that govern the control�s position and appearance.

Description : Define what is the difference between compile-time polymorphism and run-time polymorphism?

Last Answer : Compile time Polymorphism Compile time Polymorphism also known as method overloading. Method overloading means having two or more methods with the same name but with different signatures. Run time ... or more methods with the same name, same signature but with a different implementation.

Description : Does an object need to be made to run main?

Last Answer : No

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 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 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 : Briefly highlight the differences between imperative and declarative security as they pertain to code access security.

Last 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 ... request assembly-wide permissions using the Assembly (assembly) directive with declarative security.

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 : What is unsafe code?

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

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 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 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()); } } } }

Description : Write some code using interfaces, virtual methods, and an abstract class.

Last Answer : using System; public interface Iexample1 { int MyMethod1(); } public interface Iexample2 { int MyMethod2(); } public abstract class ABSExample : Iexample1, Iexample2 { public ABSExample( ... override void VIRTMethod2() { System.Console.WriteLine("VIRTMethod2 has been overridden"); } }

Description : Why is the virtual keyword used in code?

Last Answer : The Virtual keyword is used in code to define methods and the properties that can be overridden in derived classes.

Description : Define what is a code group?

Last Answer : A code group is a set of assemblies that share a security context.

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 : Describe how to use a DataView to filter or sort data.

Last Answer : You can apply sort criteria to a DataView by setting the Sort property to the name of a column or columns to be sorted by. The data represented in a DataView object can be filtered by setting the RowFilter property to a valid filter expression.

Description : Describe a general strategy for creating a setup project that terminates installation if a specific file is not already installed on the target machine.

Last Answer : First, create a file search to search the file system for the specific file. Then create a launch condition to evaluate the results of the search. You can connect the launch condition to ... in the search's Property property in the expression specified by the launch condition's Condition property. 

Description : Describe XCOPY deployment. Under what conditions is it useful? When can it not be used?

Last Answer : XCOPY deployment is a simple method of deployment where the DOS command XCOPY is used to copy the application directory and any subdirectories to the target machine. You can use XCOPY ... an application requires a more complex deployment or references shared assemblies, you cannot use XCOPY.

Description : Describe how to sign your assembly with a strong name. Why would you want to do this?

Last Answer : To sign your assembly with a strong name, you must have access to a key file or create one with the strong name utility (sn.exe). You then specify the key file in the AssemblyInfo file and ... identity, a strong name is required if you want to install your assembly to the Global Assembly Cache.

Description : Describe how to create localized versions of a form.

Last Answer : To create a localized version of a form, set the Localizable property to true. Then set the Language property to the language/region for which you want to create the localized form. Make ... be stored in resource files and loaded when the CurrentUICulture is set to the appropriate CultureInfo. 

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 : Describe how to create a form or control with a nonrectangular shape.

Last Answer : Set the Region property of the form or control to a Region object that contains the irregular shape. You can create a Region object from a GraphicsPath object.

Description : Describe the role of the LicenseProvider in control licensing.

Last Answer : The LicenseProvider controls license validation and grants run-time licenses to validly licensed components. The LicenseManager.Validate method checks for an available license file and checks ... of LicenseProvider. You specify which LicenseProvider to use by applying the LicenseProviderAttribute. 

Description : Describe the general procedure for rendering text to a drawing surface.

Last Answer : You must first obtain a reference to a Graphics object. Next, create an instance of a GraphicsPath object. Use the GraphicsPath.AddString method to add text to the GraphicsPath. Then, call the Graphics.DrawPath or Graphics.FillPath to render the text.

Description : Describe the roles of Graphics, Brush, Pen, and GraphicsPath objects in graphics rendering.

Last Answer : The Graphics object represents a drawing surface and encapsulates methods that allow graphics to be rendered to that surface. A Brush is an object that is used to fill solid shapes, and a Pen ... lines. A GraphicsPath object represents a complex shape that can be rendered by a Graphics object.

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 : 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 : Describe Break mode and some of the available methods for navigating in Break mode.

Last Answer : Break mode allows you to observe program execution on a line-by-line basis. You can navigate program execution in Break mode by using Step Into, Step Over, Step Out, Run To Cursor, and Set Next Statement.

Description : Describe an abstract class and explain when one might be useful.

Last Answer : An abstract class is a class that cannot be instantiated but must be inherited. It can contain both implemented methods and abstract methods, which must be implemented in an inheriting class. ... common interface for other methods, and leave more detailed implementation up to the inheriting class.

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 : Describe what is meant by field-level validation and form-level validation.

Last Answer : Field-level validation is the process of validating each individual field as it is entered into a form. Form-level validation describes the process of validating all of the data on a form before submitting the form.

Description : Describe two ways to set the tab order of controls on your form.

Last Answer : You can set the tab order in Visual Studio by choosing Tab Index from the View menu and clicking each control in the order you desire. Alternatively, you can set the TabIndex property either in code or in the Properties window.