Important Facts

Length-1 of specified dimension of the array
Different between array Length and Rank
Rank of an array is number of dimensions of an array and Length is total number of elements of an array.
Ex:-
class Class1
    {
        public static void Main()
        {

            int[,] numbers = new int[3, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
            Console.WriteLine("Length of the numbers array is:-" + numbers.Length);
            Console.WriteLine("Rank of the numbers array is:-" + numbers.Rank);

            Console.WriteLine("------------*************************-------------");
            Console.WriteLine("------------*************************-------------");

            string[, ,] lettres = new string[3, 2, 2];
            Console.WriteLine("Length of the letters array is:-" + lettres.Length);
            Console.WriteLine("Rank of the letters array is:-" + lettres.Rank);

            Console.ReadLine();
        }

    }

OutPut:-
Length of the numbers array is:-6
Rank of the numbers array is:-2
----------*************************-------------
----------*************************-------------
Length of the letters array is:-12
Rank of the letters array is:-3


Upper bound of an Array

Ex:- string[, ,] lettres = new string[3, 7, 2];
    Console.WriteLine("Upperbound the Array is:-" + lettres.GetUpperBound(0));
    Console.WriteLine("Upperbound the Array is:-" + lettres.GetUpperBound(1));
    Console.WriteLine("Upperbound the Array is:-" + lettres.GetUpperBound(2));

Output:-
Upperbound the Array is:-2
Upperbound the Array is:-6
Upperbound the Array is:-1


Constructors and Destructors

  •  Destructors are not used with structures.
  •  A class can have only one destructor.
  • Static constructors can't use optional arguments but Overloaded constructors can use optional arguments. 
  • Constructors always have the name same as the name of the class.
  • Constructors are never called explicitly.
  • Constructors never return any value.
  • Only one time a object can call a constructor during it's lifetime.

 Functions
  • Return value cannot be used to distinguish between two overloaded functions.

Ex:- following class will give compilation error
lass MainClass
    {
       public int MyFunc()
        {
            -------
        }                          
        public float MyFunc()
        {
            -------
        }
    }
  • To be treated as overloaded method at least one of the following should fulfilled,
    1. Type of arguments should differ from each other
    2. Number of arguments should differ from each other
    3. Order of arguments should differ from each other
Static and Instant data
  • Instant data can’t access by static function. Static functions can access only static data.
  • Static functions cannot call instance functions.
  • Instance functions can call static functions and access static data.
String
The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.
compareTo method in string class used to compare two strings if both were matching it will return one otherwise will return -1.
String s1 = "Five Star";
            String s2 = "FIVE STAR";
            int c;
            c = s1.CompareTo(s2);
            Console.WriteLine(c); //Output -1

Namespaces 
  • Namespaces help us to control the visibility of the elements present in it.
            display and Visibility in CSS
                      using display attribute in CSS ypu can specify the displaying method of your field. 
                      but if you use Visibility it will not exclude the white spaces during the fields invisible

No comments:

Post a Comment