Tech News

C# Cheat Sheet

C# Language Cheat Sheet: Built-In C# Methods With Descriptions

Conversion Methods
ToBoolean
Converts a type to a Boolean value, where possible
ToByte
Converts a type to a byte
ToChar
Converts a type to a single Unicode character, where possible
ToDateTime
Converts a type (integer or string type) to date-time structures
ToDecimal
Converts a floating point or integer type to a decimal type
ToDouble
Converts a type to a double type
ToInt16
Converts a type to a 16-bit integer
ToInt32
Converts a type to a 32-bit integer
ToInt64
Converts a type to a 64-bit integer
ToSbyte
Converts a type to a signed byte type.
ToSingle
Converts a type to a small floating point number
ToString
Converts a type to a string
ToType
Converts a type to a specified type
ToUInt16
Converts a type to an unsigned int type
ToUInt32
Converts a type to an unsigned long type
ToUInt64
Converts a type to an unsigned big integer
Regex Class Methods
public bool IsMatch(string input)
Indicates whether the regular expression specified in the Regex constructor finds a match in a specified input string
public bool IsMatch(string input, int startat)
Indicates whether the regular expression specified in the Regex constructor finds a match in the specified input string, beginning at the specified starting position in the string
public static bool IsMatch(string input, string pattern)
Indicates whether the specified regular expression finds a match in the specified input string
public MatchCollection Matches(string input)
Searches the specified input string for all occurrences of a regular expression
public string Replace(string input, string replacement)
In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string
public string[] Split(string input)
Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the Regex constructor
Thread Class Methods
public void Abort()
Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread
public static LocalDataStoreSlot AllocateDataSlot()
Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead
public static LocalDataStoreSlot AllocateNamedDataSlot(string name)
Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead
public static void BeginCriticalRegion()
Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain
public static void BeginThreadAffinity()
Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread
public static void EndCriticalRegion()
Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task
public static void EndThreadAffinity()
Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread
public static void FreeNamedDataSlot(string name)
Eliminates the association between a name and a slot, for all threads in the process. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead
public static Object GetData(LocalDataStoreSlot slot)
Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead
public static AppDomain GetDomain()
Returns the current domain in which the current thread is running
public static AppDomain GetDomainID()
Returns a unique application domain identifier
public static LocalDataStoreSlot GetNamedDataSlot(string name)
Looks up a named data slot. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead
public void Interrupt()
Interrupts a thread that is in the WaitSleepJoin thread state
public void Join()
Blocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms
public static void MemoryBarrier()
Synchronizes memory access as follows: The processor executing the current thread cannot reorder instructions in such a way that memory accesses prior to the call to MemoryBarrier execute after memory accesses that follow the call to MemoryBarrier
public static void ResetAbort()
Cancels an Abort requested for the current thread
public static void SetData(LocalDataStoreSlot slot, Object data)
Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the ThreadStaticAttribute attribute instead
public void Start()
Starts a thread
public static void Sleep(int millisecondsTimeout)
Makes the thread pause for a period of time
public static void SpinWait(int iterations)
Causes a thread to wait the number of times defined by the iterations parameter
public static byte VolatileRead(ref byte address)
public static double VolatileRead(ref double address)
public static int VolatileRead(ref int address)
public static Object VolatileRead(ref Object address)
Reads the value of a field. The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache. This method has different overloaded forms. Only some are given above
public static void VolatileWrite(ref byte address,byte value)
public static void VolatileWrite(ref double address, double value)
public static void VolatileWrite(ref int address, int value)
public static void VolatileWrite(ref Object address, Object value)
Writes a value to a field immediately, so that the value is visible to all processors in the computer. This method has different overloaded forms. Only some are given above
public static bool Yield()
Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to

No comments:

Post a Comment