Home
C-Sharp
Interview FAQs

Show

FAQs of level

Intermediate

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.

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+"\""); }
}
}

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.

FileInfo fi = new FileInfo(FileUpload1.FileName);
MessageBox.Show("File extention : " + fi.Extension.ToString());
A thread is an independent stream of instructions in a program.

OR

You can say - A thread is the basic unit to which the operating system alocates the processor time.

Threads are manipulated using the class "Thread", which can be found in the "System.Threading" namespace. An instance of thread represents one thred, or one sequence of execution. You can create another thread by simply instantiating another instance of thread object.

Threads execution can be paused by calling the "Thread.Sleep()" method. This method takes an integer value as its parameter that determines how long the thread should pause. the thread will simply not run for the specified time period, which also means it will not take up any processor time while it is in sleep. It will immediatly place a thread in wait state.
If a thread is aborted by using "Thread.Abort()" method, it will stop running altogether. Windows will permanently destroy all data that it maintains relating to that thread, so the thread subsequently cannot be restarted after it is aborted.
Thread.Suspend() block a thread until another thread call Thread.Resume().
Displaying 1 of 4Next
1 2 3 4
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*