How do you declare a static variable and what is its lifetime? Give an example.

static int Myint–The life time is during the entire application. OR The static modifier is used to declare a static member, which belongs to the type itself rather than to a specific object. The static modifier can be used with fields, methods, properties, operators, events and constructors, but cannot be… Continue reading

How to increased array length dynamically?

public static Array ExpandArray(Array arr, object newElement) { int length = 1; System.Type type = newElement.GetType(); if (arr != null) { length += arr.Length; type = arr.GetType().GetElementType(); } Array result = Array.CreateInstance(type, length); if (arr != null) { arr.CopyTo(result, 0); } result.SetValue(newElement, result.Length – 1); return result; }