Interview Questions → CSHARP 2.0 → C# 2.0 Questionnaire I

C# 2.0 Questionnaire I







string str1 = null;

string str = Convert.ToString(str1);
	   








string str1 = null;

string str = str1.ToString();
	   












[Obsolete]
public string Test()
{
  return "this is obselete method";
}
	   




string str = Test();
	   








public struct MyStruct : MyInterface
{
  public void Display()
  {
      //DO something
  }
}

public interface MyInterface
{
  void Display();
}








public class class123
{
    public string display()
    {
        return "Hi";
    }
}

public class class456 : class123
{
    public new string display()
    {
        return "Hello";
    }
}










protected void Page_Load(object sender, EventArgs e)
{
    int a  , b;
    Increment(ref a, ref b);
}
public void Increment(ref int x, ref int y)
{
    x= 0;
    y= 0;            
    x++;
    y++;
}











protected void Page_Load(object sender, EventArgs e)
{
    int a  , b;
    Increment(out a, out b);
}
public void Increment(out int x, out int y)
{
    x= 0;
    y= 0;            
    x++;
    y++;
}








public interface I1
{
     string Display();
}
public interface I2
{
     string Display();
}




public class Class1 : I1,I2
{
    string I1.Display()
    {
        return "Hello"; 
    }
    string I2.Display()
    {
        return "hi";
    }
}




Class1 obj = new Class1();




I1 obj1 = (I1)obj;
string str1 = obj1.Display(); //Will execute the Display function of interface I1
I2 obj2 = (I2)obj;
string str2 = obj2.Display(); //Will execute the Display function of interface I2






public sealed class MyClass
{
    public void Get()
    { }
}

public class SecondClass : MyClass
{
    public virtual void print()
    {
        MessageBox.Show("Print");
    }
}












<form id="frmTest" runat="server">
    <div>
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
    </div>
 </form>




Page.RegisterClientScriptBlock("Test", "<script type='text/javascript'>document.frmTest.txtName.focus();</script>");












Page.RegisterStartupScript("Test", "<script type='text/javascript'>document.frmTest.txtName.focus();</script>");










public class MainClass
{
    public virtual void Test()
    { }
    
}
public class SecondClass : MainClass
{
    public override void Test()
    { }
}


















Posted By  -  Karan Gupta


Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250