Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Part 20 - C# Tutorial - Static and instance class members


Part 20 - C# Tutorial - Static and instance class members


12 comments:

  1. Great Videos thank you I was getting lost at school but these videos are really helping me to understand what is going on

    ReplyDelete
  2. very good Videos for free of cost...Thanks Gr8 help

    ReplyDelete
  3. Hi Venkat
    Please add this topic in text also. Besides this, I would request you one thing, your blog opens with VPN in office. Could you please make it available in office network so that anyone can read the articles in office network also.Thanks

    ReplyDelete
  4. Hi Venkat, I am learning C# from your youtube channel, its a great help for guys like me, and I appreciate you for the same.
    I have a question for you, I have learned about static and instance class methods, but I am finding myself unable to decide that in which scenario or situation I should make the method static or keep it instance method. How to decide this? Kindly help me with some simple example. But kindly notice that I am an absolute beginner hence illustrate this me in simplest way possible. Thanks very much in advance.

    ReplyDelete
    Replies
    1. hi Kumar, i think we should use Static method if the method is useful, we need use it lots of times. in that case, if we set the method as intance method, we need to invoke a instance class every time to use that method, the cost of the memory is too huge. So as my understanding, we should use Staic method if the method always be called, such as Console.writeLine().
      it's just my personal idea, hope we can share ideas.

      Delete
    2. Asking a question to replied one,
      instance members are took too much of memory then why we are using instance members/methods instead of static once

      Delete
  5. Hi Venkat,

    Why I cannot write Console.Writeline(This is instance constructor ); below the return statement ?

    ReplyDelete
    Replies
    1. as far as I understand return statement is declared at the end of your class statements and thus it returns a value as required , in other words your compiler expects to end the program once you return the value

      Delete
    2. I have asked the same question to my tutor he said that since return statement once executed brings u out of that block or loop so statements written after (Return) are unreachable.

      Delete
  6. Thank you for this great detailed presentation on Static and Instance Members. I was all confused till now. Your are an excellent instructor.
    Jonathan

    ReplyDelete
  7. sir i am new in c# i have no idea about C#.So plz teach me the Basic things Of c#.very thankul to u.

    ReplyDelete
  8. text
    class Circle
    {
    static float _PI = 3.141f;
    int _Radius;

    public Circle(int Radius)
    {
    this._Radius = Radius;
    }

    public float ClacArea()
    {
    return Circle._PI * this._Radius * this._Radius ;

    }
    ~Circle ()
    {
    //Clean up Code
    }
    }
    static void Main(string[] args)
    {
    Circle c1 = new Circle(5) ;
    float Area= c1.ClacArea();
    Console.WriteLine("Area {0}", Area);

    Circle c2 = new Circle(6);
    float Area2 = c2.ClacArea();
    Console.WriteLine("Area {0}", Area2);

    }

    ReplyDelete

It would be great if you can help share these free resources