string for creating variable
//string name = "Sam"
String for class methods and reference
// String.Concat(name, name2)
2) Count Occurrences of a String
Use Regex.Matches(), Not use Loop
3) Break vs Continue
Break - Exit Immediately
Continue - allow loop to continue (Stop the current and continue next )
5)
String can be null (reference type)
Datetime not null (value type )
6)
double x = 5.0;
int y =5;
console.writeline(x==y);
7) Ref vs Out
ref tells the compiler that the object is initialized before entering the function.
out tells the compiler that the object will be initialized inside the function.
ref is two-ways
out is out-only. (1 way )
out not allowed to leave it unassigned.
int a, b;
swap(ref a, ref b); Compile Error (ref)
int a = 0;
int b = 0;
swap(ref a, ref b); Right (ref)
int a, b;
swapOut(out a, out b); Right (out)
static void swapOut(out int o, out int p)
{
int x = 0;
x =
o; Error(Out is not allow to assign);
x = 1000;
p =
2000;
}
10)Inheritance
If Parent have constructor, child also must have constructor
public Rectangle(double l, double w) //Parent
{
length = l;
width = w;
}
public Tabletop(double l, double w) : base(l, w) //Child
{
}
10)Const Vs Readonly
const must be initialized, initialization must be at compile time
readonly can use default value, without initializing. initialization can be at run time
11)Convert.tostring vs .tostring()
Convert.tostring handle null.
Tostring() not handle null.
10)Const Vs Readonly
const must be initialized, initialization must be at compile time
readonly can use default value, without initializing. initialization can be at run time
11)Convert.tostring vs .tostring()
Convert.tostring handle null.
Tostring() not handle null.