Tuesday, March 12, 2013

c# interview questions (intermediate)

  • is the LINQ Any operator a linear search?
  • what patterns have you used in your code?
  • if you needed to implement a process that had sub process A,B,C,D,E and B and D changed in detail in 5 situations - how would you model this?
  • what is the Big O notation of a binary search?
  • Can you describe how a hash table works?
  • how can you add a compiler warning?
    •        #warning
  • Can you implement an interface that is using a base object with an implementation that is using a descendant class?
  • how can you get the members of a class progromatically?
    •         Type t = typeof(blah); MemberInfo[] m =  t.GetMembers();
  • how can you alert a user of your class that a procedure is obsolete?
    •          [Obsolete("hody doe")]
  • can a private member ever be available to a different class without reflection?
    •        Nested classes
  • can you change the name of a rerefenced class to something else?
    •        alias  - using msg = System.Windows.Forms.MessageBox; 
  • var test = new { herby = "hello", age = 67f } what type is this?
    • anonymous - system generated name
  • what is the meaning of checked and uchecked keyword in c#?
  • What type of objects are able to be queried by linq?
  • when you have a readonly variable pointing to an object, can you change the value of the object?
  • How would you reference a custom attribute added to a object?
    • GetCustomAttributes, reflection
  • Why are strings immutable in c#
  • Which Interface would you implement for deep copying?
    • ICloneable
  • How can you add functionality to a sealed class?
    • extension method
  • How would encapsulate a reference type like a list as a member of a class to be read only?
  • how to have a generic procedure make sure whatever is being passed implements an interface properly  
    • void SwapIfGreater<T>(ref T lhs, ref T rhs) where T : System.IComparable<T>
  • How to Explicitly Implement Members of Two Interfaces 
    • interface IA
          {
               void hody();
          }

          interface IB
          {
               void hody();
          }

          class HodyDoe : IA, IB
          {
              void IA.hody()
              {
                  Console.WriteLine("IA.hody"); 
              }

              void IB.hody()
              {
                  Console.WriteLine("IB.hody"); 
              }
          }
         
          class Program
          {
              static void Main(string[] args)
              {

                  HodyDoe h = new HodyDoe();
                  (h as IA).hody();
                  (h as IB).hody();
                  Console.ReadLine(); 

              }
          }



No comments:

Post a Comment