• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/48

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

48 Cards in this Set

  • Front
  • Back
What method causes settings to be read from an IConfigurationSectionHandler object
Create

Create is the only method that needs to be impl'ed in this interface
how do you force changes in a StreamWriter to be sent to the stream it is writing to
Any of :
- Close
- AutoFlush of StreamWriter to true
- Flush
What is MarshelAs attribute for?
The purpose of it is type mapping by explicitly defining relationships (although it is not always necessary).
Which encoding types support Chinese?
UTF-8
UTF-16
UTF-32
Can Path.ChangeExtension change file extension to the file system?
No. It only deals with the string of a path
How to open or create (if not existing) a file stream for writing?
- Create a FileStream instance with FileMode.OpenOrCreate

or

- File.Open with FileMode.OpenOrCreate
What is necessary to make an assembly visible to a COM component?
- Set ComVisible to true for any class members you want visible
- Set ComVisible to true for any classes you want visible
- Set "Register for COM" option under the build configuration
- Set ComVisible to false for any class members you want hidden
what types of collection you can make from CollectionUtil
- case-insensitive SortedList
- case-insensitive Hashtable

Not

- Culture-invariant Hashtable
- Case-insensitive StringDictinary
Which classes or interfaces can be used to provide custom configuration manipulation?
Option1.
IConfigurationSectionHandler
example:
public class MyHandler : IConfigurationSectionHandler
{
#region IConfigurationSectionHandler Members

object IConfigurationSectionHandler.Create(
object parent, object configContext, XmlNode section)
{
throw new Exception("The method is not implemented.");
}

#endregion
}

Option2.

ApplicationSettingsBase

example:

//Application settings wrapper class
sealed class FormSettings : ApplicationSettingsBase
{
[UserScopedSettingAttribute()]
public String FormText
{
get { return (String)this["FormText"]; }
set { this["FormText"] = value; }
}

[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("0, 0")]
public Point FormLocation
{
get { return (Point)(this["FormLocation"]); }
set { this["FormLocation"] = value; }
}

[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("225, 200")]
public Size FormSize
{
get { return (Size)this["FormSize"]; }
set { this["FormSize"] = value; }
}


[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("LightGray")]
public Color FormBackColor
{
get { return (Color)this["FormBackColor"]; }
set { this["FormBackColor"] = value; }
}

}

Option 3. ConfigurationSection (see other flashcard)
Can ConfigurationValidatorBase or IConfigurationSystem be used to provide custom configuration manipulation?
No.

ConfigurationValidatorBase is used to create a custom validator. A custom validator can be used to verify object values.
e.g. CallbackValidator, DefaultValidator, IntegerValidator, LongValidator, StringValidator, etc.

IConfigurationSystem is not intended to be used directly from your code.
How do you specify a stream into which to write compressed data with DeflateStream class?
when creating the instance of the class with the constructor.

e.g

DeflateStream compressedzipStream = new DeflateStream(theStream , CompressionMode.Compress, bLeaveStreamOpenOrNot);
Which method to use to determine if the current assembly has a specific permission without throwing an exception?
SecurityManager.IsGranted(permission)
Is EventHandler is generic type?
Yes.

Example:

public class MyEventArgs : EventArgs
{
private string msg;

public MyEventArgs(string messageData)
{
msg = messageData;
}
public string Message
{
get { return msg; }
set { msg = value; }
}
}

class Program
{
// Declare an event of delegate type EventHandler of
// MyEventArgs.





public static event EventHandler<MyEventArgs> SampleEvent;
public static void Main()
{
ListenEvent le = new ListenEvent();
SampleEvent += new EventHandler<MyEventArgs>(ListenEvent.SampleEventHandler);
OnDemoEvent("Hey there, Bruce!");
OnDemoEvent("How are you today?");
OnDemoEvent("I'm pretty good.");
OnDemoEvent("Thanks for asking!");
}

public static void OnDemoEvent(string val)
{
// Copy to a temporary variable to be thread-safe.
EventHandler<MyEventArgs> temp = SampleEvent;
if (temp != null)
temp(null , new MyEventArgs(val));
}

}
What should be done to use a structure for a given P/invoke call?
Step1. Define the structure
Step2. (Optional) use SizeOf of System.Runtime.Marshal
Step3. (Optional) use StructLayout attribute if positioning within the structure is important
Size limitation on GZipStream compress?
Any data/file no larger than 4GB
What permissions required for all console applications running with a debugger
UIPermission
Give Two ways to run an assembly as if it were located on the Internet
Option 1.

//C#
object[] hostE = {new Zone[SecurityZone.Internet]};
Evidence = new Evidence(hostE, null);
AppDomain myDomain = AppDomain.CreateDomain("MyDomain", e);
d.ExecuteAssembly("Assembly.exe");

Option 2.
//C#, use ExecuteAssembly method

Evidence e = new Evidence();
e.AddHost(new Zone(SecurityZone.Internet));
AppDomain ap = AppDomain.CreateAppDomain("MyDomain");
ap.ExecuteAssembly("Assembly.exe", e);
What class allow dynamic creation of assembly?
AppDomain

(because appdomain returns assembly builder which returns modulebuilder ...)
How to easily perform case-insensitive string comparison?
Passing CompareOptions.IgnoreCase to Compare method of CompareInfo instance
What methods can be used to revert security restrictions?
// Causes all previous overrides for the current frame to be removed and no longer in effect.
CodeAccessPermission.RevertAll()
// Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance
CodeAccessPermssion.RevertPermitOnly()
Which methods allow COM components to be used in .NET applications
1. Ensure that the app is registered using the RegSvr tool if necessary, Then either add a reference to it from the COM tab of the Add Reference dialog box or use TblImp.exe. OR
2. Add a reference to the component thru VS 2005
OR
3. Use the Type Library Import Tool (Tbllmp.exe)
What tool is used to create a COM consumable type?
TlbExp.exe
How do you make sure to isolate trace from one logic operation from the other?
use CorrelationManager object to keep each trace isolated
What's the requirements for a class to be able to serialize to XML?
1. parameterless constructor AND
2. public
Is typed declared Nullable reference type?
Not necessary.

Example:

Nullable<int> i = null;
How to get the current culture of the application
Option 1.

Thread.CurrentThread.CurrentCulture OR

Option2.
Create an instance of the CultureInfo class using a specific culture, and check the CurrentCulture property
What the .NET Framework 2.0 Configuration tool can do?
View all assemblies in GAC, AND
View all configured applications
Acceptable ways to open a file for writing?
File.Open("some.txt", FileMode.Create); OR
File.Open("some.txt", FileMode.Create. FileAccess.Write); OR
FileInfo file = new FileInfo("some.txt");
file.Open(FileMode.Create);
How to open configure file using ConfigurationManager?
openExeConfiguration
openMachineConfiguration
openMappedExeConfiguration
openMappedMachineConfiguration
What methods can be used to create new IsolatedStorageFile object?
GetStore
GetMachineStoreForAssembly
GetUserStoreForAssemly
what types to store fractional numbers in .NET?
double, float, decimal(128bit or 16bytes)
How to start a service?
// use ServiceController - instance method
ServiceController sc= new ServiceController("Server");
sc.Start();
Given a type, what the ways to get all methods of it? which is the most efficient way?
Option 1.
Type myType = Type.GetType("MyTypeName");
MethodInfo[] mis = myType.GetMethods();
foreach(MethodInfo mi in mis) {
// list them ...Name
}

Option 2.

Type myType = Type.GetType("MyTypeName");
MemberInfo[] mis = myType.getMembers();
foreach(MemberInfo mi in mis) {
if (mi.MemberType = MemberTypes.Method) {
// list ....Name
}

Option 1 is the most efficient
}
Does StringBuilder allow "+" and "+="?
No.

Example:

string s = null;
StringBuilder sb = null;
sb.Append("Hello");
sb.Append(", World!");
s = sb.ToString();
How to bind the reference of classes from 3rd party assembly to its diffrent (newer) version?
By using .NET Framework 2.0 Configuration tool. The binding redirection or binding policy feature, under MyComputer -> Configured Assemlies (which are under GAC)
A class (i.e. impl ISerializable) that supports custom serialization must provide constructor like xxx(SerializationInfo, StreamingContext) for deserialization purpose, where the data for de/serialization from? example?
The data is from SerializationInfo's GetValue method. StreamingContext just provides the source that has the serialized data.
What's the purpose of SerializationInfo?
to store all the data needed to serialize or deserialize an object. This class cannot be inherited. such as name, type and data for each piece of info that serialized/deserialized.

Add/GetValue() // by name/type
Set/GetType() // of current instance
What's the purpose of StreamingContext?
Describes the source and destination of a given serialized stream, as well as a means for serialization to retain that context.

properties:
State: During serialization, the destination of the transmitted data. During deserialization, the source of the data.

Context: additional context
Meaning of FullControl, Modify
FullControl/Allow: can modify the file/dir and its permissions

Modify/Allow: can edit but cannot change its permssions (i.e. FullControl/Allow + ChangePermissions/Deny)
RegEx -- Groups start from 0 or 1?
1
DriveInfo:
1. How to get C drive's type?
2. Does it have GetDriveType() static method?
3. DriveInfo.GetDrives example?
1.

DriveInfo di = new DriveInfo(@"C");
return di.DriveType == DriveType.Fixed;

2. No

3.

using System;
using System.IO;

class Test
{
public static void Main()
{
DriveInfo[] allDrives = DriveInfo.GetDrives();

foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(
" Available space to current user:{0, 15} bytes",
d.AvailableFreeSpace);

Console.WriteLine(
" Total available space: {0, 15} bytes",
d.TotalFreeSpace);

Console.WriteLine(
" Total size of drive: {0, 15} bytes ",
d.TotalSize);
}
}
}
}
/*
This code produces output similar to the following:

Drive A:\
File type: Removable
Drive C:\
File type: Fixed
Volume label:
File system: FAT32
Available space to current user: 4770430976 bytes
Total available space: 4770430976 bytes
Total size of drive: 10731683840 bytes
Drive D:\
File type: Fixed
Volume label:
File system: NTFS
Available space to current user: 15114977280 bytes
Total available space: 15114977280 bytes
Total size of drive: 25958948864 bytes
Drive E:\
File type: CDRom

The actual output of this code will vary based on machine and the permissions
granted to the user executing it.
*/
What's managed classes corresponding to the following unmanaged classes:

HANDLE,
LPSTR,
WORD,
INT/LONG/BOOL,
DOUBLE
HANDLE: IntPtr
LPSTR: String
WORD: UInt16
INT/LONG/BOOL: Int32
DOUBLE: Double
Why Isolated storage should not be used for high-value secrets? What data is it suitable for?
isolated storage is not protected from highly-trusted code, unmanaged code, trusted users of the computer.

It is suitable for per-user or user preference data (not configuration settings because admin does not control them)
To create a custom trust manager to determine if a app can be exe'ed and what permissions should be granted, what IF should be impl'ed?
IApplicationTrustManager

.DetermineApplicationTrust
How to create an custom uninstall?
Step1. Create a new AssemblyInstaller or ComponentInstaller
Step2. Specify the name of the assembly or application
Step3. Call the Uninstall method
What can/cannot marshaled between managed and unmanaged code?
cannot: generic types
can: arrays, booleans, char types, delegates, classes, objects, strings, structures
What is IAsyncResult.AsyncState for?
What param a AsyncCallback delegate receive?
It is for storing the object for the completed request; it has to be cast to the proper type.

one param: IAsyncResult object.
What the difference of comparing object in VB and C#?
VB: the value (content) of objects (e.g. string)

C#: the reference of objects (e.g. even the "string comparison" result is true)