| What is maximum dimension technically posible in C#? |
| 60 |
|
|
|
|
|
| In C#, for String class Equals means value equality or reference equality? |
| The default implementation of Equals supports reference equality only, but derived classes can override this method to support value equality. Reference equality occurs when two reference type objects refer to the same object. Sometimes reference types need to define value equality instead of reference equality. Fortunately, the Equals method is virtual, so derived reference types may override it. |
|
|
|
|
|
| How to loop through a list of files in a directory? |
| This looks at all files ending in ".cs"
using System;
using System.IO;
public class Temp
{
public static void Main(string[] args) {
DirectoryInfo di = new DirectoryInfo(".");
foreach(FileInfo fi in di.GetFiles("*.cs")) {
Console.WriteLine("Looking at file \""+fi.FullName+"\"");
}
}
} |
|
|
|
|
|
| Can I use inline assembly or IL in C# code? |
| No. |
|
|
|
|
|
| How do I create an instance of a type if I only know its name? |
| This is a two stage process. Firstly, you need to get a Type reference for the type. If the type you want to create an instance of is in either mscorlib or the current assembly, you can just use Type.GetType(name). If it is in a different assemby, you could either call Type.GetType and pass in the full type name including assembly information, or you could find or load the assemnbly and then call Assembly.GetType(name) on that assembly reference. Once you have got a Type reference, you can either use Activator.CreateInstance(type) to create an instance, or call Type.GetConstructor to get a specific constructor which you can then use to create an instance by calling Invoke on it. |
|
|
|
|
|