C# aka. "C sharp" is a programming language runs on the .NET Framework and used for building a variety of applications. C# is type-safe, powerful and object-oriented.
What is an object?
What is Constructors?
[Access Modifier] ClassName([Parameters]) { }Example of default constructor:
public class MyClass { public MyClass() { } }
Types of Constructors
Default Constructor
Parameterized Constructor
Copy Constructor
Static Constructor
Private Constructor
What is the difference between ref & out parameters?
What is difference between constants and read-only
A const field can only be initialized at the declaration of the field. A "Const" field is a compile-time constant.
A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. The readonly field can be used for runtime constants.
What are value types and reference types?
Ex. int, enum , byte, decimal, double, float, long
Variables those holds reference to the actual data are of "Reference" types.
Ex. string , class, interface, object
What are sealed classes in C#?
What is method Overloading?
//Overloading public class OverloadClass { public void someMethod(int id) {} public void someMethod(string name) {} }
What is method Overriding?
//Overriding public class OverridingClass { public virtual someMethod(int id) { //Get stuff default location } } public class test2 : test { public override someMethod(int id) { //base.getStuff(id); //or - Get stuff new location } }
What is the difference between Array and Arraylist?
Which are Access Modifiers available in C#?
You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
public: The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private: The type or member can be accessed only by code in the same class or struct.
protected: The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.
What is static constructor?
What is Reference Type in C# ?
Employee emp1; Employee emp2 = new Employee(); emp1 = emp2;Here emp2 has an object instance of Employee Class. But emp1 object is set as emp2. What this means is that the object emp2 is referred in emp1, rather than copying emp2 instance into emp1. When a change is made in emp2 object, corresponding changes can be seen in emp1 object.
What is Abstract Class in C#?
abstract class Car { public Car() { Console.WriteLine("Base Class Car"); } public abstract void DriveType(); } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } }Method DriveType get implemented in derived class.
What is Sealed Classes in c# ?
public sealed class Car { public Car() { Console.WriteLine("Base Class Car"); } public void DriveType() { Console.WriteLine("Right Hand "); } }
What is the use of var keyword in C#?
eg.
var age = 10;Because the initialization value (10) of the variable age is integer type of age will be treated as integer type of variable. There are few limitation of the var type of variables.