Basic of C#

Posted on Updated on

C-To-Go-300x300What is an Object?

  • An object can be viewed as a “thing” that can perform an arrangement of related exercises.
  • Any genuine entity.

For example:

  • The hand can grip something.
  • A fish in water (fish is an object).
  • An thought comes in your brain, and you execute it (the thought is an object).
  • Fruit in an plantation (fruit is an object).

What is a Class?

A class is essentially a representation of a kind of object. It is the diagram/ arrangement/ layout that portrays the points of interest of an object. A class is the outline from which the individual objects are made.

For example:

Take an illustration of a bowl in which you can bake a cake, the cake could be of different flavors so cake is my class and its flavors are objects.

untitled

CODE:

How can you create a class and object in C#?

untitled

Why method of main is static?

Static routines can’t be gotten to by an object, yet can be gotten to by the class.

Why ReadLine or Readkey?

ReadLine takes the entire line and we can zoom our window by squeezing more than one key while ReadKey takes an expression and back to the code window.

What is the concept of method?

All methodologies done by an object could be a strategy. A system is similar to an individual, my peon is my method, I called my peon and assigned some task, or remote is my strategy I do call remote and moderate AC.

  • Data type of method.
  • Access modification.
  • Method name.
  • Method definition
  • Method declaration
  • Method call.
  • Parameters.
  • Method signature.

untitled

untitled

C# sum two numbers: 

untitled

Output: 11

What is Method overload?

Inside the same class more than one method can exist but with different parameters.

Code:

untitled

So what did you learn from overloading?

  • There could be two or more methods with the same name.
  • But with a different number of parameters of the same data type.
  • Or with a different data type of the same number of parameters.
  • There could be two or more methods with a different signature.
  • When the number of parameters is the same then the data type of the parameter is different or vice versa.

“In two different classes there could be methods with same name.”

untitled

What is Method Overriding?

Method overriding is a language feature that allows a subclass to override a specific implementation of a method that is already provided by one of its super-classes.
A subclass can give its own definition of methods but needs to have the same signature as the method in its super-class. This means that when overriding a method the subclass’s method has to have the same name and parameter list as the super-class’s overridden method.

What is Abstraction?

Sometimes there is a class which does not create objects; this class provides a definition to other classes and this is known as an abstraction.

For example:
Consider fish is a class. In class fish there are two types of fish dolphin and sword; both have different food. An abstract class specifies that if a fish is a parent class and when the concept of inheritance is implemented;
fish says eat, after being inherited then the Dolphin says eat vegetables now I want to override the child method so we made the parent class virtual.

untitled

What is Polymorphism?

Polymorphism comes with overriding. To provide many ways to do the single thing.
Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things.

What are namespaces?

Namespace is a wrapper which groups classes together, namespace within namespace can be exist.

Interface: C# can’t perform multiple inheritance so we adopt the term “interface”. An interface is just like a class; a class is a reference type while an interface is a value type.
An interface looks like a class, but has no implementation. An interface is equal to an abstract class but an abstract class can’t perform multiple inheritances that an interface can perform.

C# code:

untitled

*****************************************************************************************************

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666
Email: info@technocampus.co.in

Please fill the form and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s