Interview Questions → CSHARP 2.0 → C# 2.0 Questionnaire III

C# 2.0 Questionnaire III













public class Engine
{}
public class Car
{
	Engine e= new Engine();
}






public class Address
{
}

public class Person
{
  private  Address _PersonAddess;
   public Address  PersonAddess
   {
	    get
	    {
		    return  _PersonAddess;
      }
      set
      {
        _PersonAddess = value;
      }
    }
}








public class A
{
    public string ConvertToString(Object obj)
    {
        string outputString;
        if (obj == null)
        {
            outputString = Convert.ToString(obj);
        }
        else
        {
            outputString = obj.ToString();
        }
        return outputString;
    }
}
public class B
{
    public string ConvertToString(Object obj)
    {
        return obj.ToString();
    }
}




public class C : A, B
{
    public void Print()
    {
        //  TODO: Doing some print operation
    }
}




C cObj = new C();
Object inputObject;
cObj.ConvertToString(inputObject);
















public class parent
{
  public virtual void Display()
  {
    Console.WriteLine("Parent Class");
    Console.ReadLine();
  }
}
public class child1 : parent
{
}




parent obj = new child1();
obj.Display();




public class parent
{
  public virtual void Display()
  {
    Console.WriteLine("Parent Class");
    Console.ReadLine();
  }
}

public class child1 : parent
{
  public override void Display()
  {
    Console.WriteLine("child1 Class");
    Console.ReadLine();
  }
}




parent obj = new child1();
obj.Display();










int a = 3;
string b = "2";
string result = string.Concat(a,b);






<script language="javascript" type="text/javascript">
	var a = 3;
  var b = "2";
  alert(a + b);
</script>










string[] alphabets = { "A", "B", "C", "D", "E", "F" };

string result = (from i in alphabets
                        where i == "G"
                select i).First();




string[] alphabets = { "A", "B", "C", "D", "E", "F" };

string result = (from i in alphabets
                        where i == "G"
                select i).FirstOrDefault();








DateTime date1 = DateTime.Now.AddHours(-19);
DateTime date2 = DateTime.Now.AddHours(-16);
Console.WriteLine(string.Format("Date2----->{0}{1}", date2, Environment.NewLine));
Console.WriteLine(string.Format("Date1----->{0}{1}", date1, Environment.NewLine));
Console.WriteLine((date2.Date - date1.Date).Days.ToString());














public int Add(int num1, int num2)
{}






int x = Add (a,b);








int[] arr = { 2, 4, 5, 1, 6 };
Array.Sort(arr);




Process[] prs = Process.GetProcesses();
foreach(Process pr in prs)
{
	if(pr.ProcessName == "Process_Name")
	pr.Kill();
}




Posted By  -  Karan Gupta


Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250