What is Object in C# ?

An object is a real-time entity by which a class comes into existence.

Without creating the object we can not use the class.

For Example:

public class MyClass
{
   int x=10;

  public void MyFunction()
  {
     Console.WriteLine(x.ToString());
   }
}

If we want to use the MyClass's MyFunction in another class then we have to create an object of MyClass in another class like below:


public class MyOtherClass
{
//  Here we want to use the MyFunction of MyClass the create an object of this.

    MyClass obj=new MyClass(); // By this line of code object will be created and stored as "obj".

   //Now by the help of this "obj" we can call the MyFunction(); as below.

   obj.MyFucntion();

}

Output: 10.

What is Inheritance in C# .Net ?

Comments

  1. Thanks for sharing to this post. It is a helpful post for developers who is working in a software development company.

    ReplyDelete
  2. Thank you for giving this useful information in this article. It's a fantastic article. I'll be waiting for your next update. I also have some useful information about the Best Custom Software Development Company in India, which I believe will be of great use to you.

    ReplyDelete
  3. Hire a developer with excellent coding standards including the author’s name, the date, the file was created, the date it was modified, how many times it had been changed, and the reason for the code.

    Hire a Developer

    ReplyDelete

Post a Comment

Popular posts from this blog

What is unqork?

What is single page Application in web applications

What is SOLID Principle ?