oops concept query

0 votes

This is my oops query.

This is my base class

public class BaseClass
{
   public int i = 10;
   public int x = 30;
   public string str = "Hello";
   public virtual string Hello()
   {
     return "Hello of base class called";
   }
}

This is my child class

public class ChildClass : BaseClass
{
    public int i = 20;
    public int z = 90;
    public override string Hello()
    {
       return "Hello of child class called";
     }
}

I've since discovered that the code below is correct.

BaseClass baseObject = new ChildClass();

And only BaseClass members are displayed when I type baseObject.

Can someone provide me any advice regarding a scenario when a developer must execute BaseClass baseObject = new ChildClass()?

Why can't I access my child member variables through this baseObject if my BaseClass object contains a reference to my child class object?

Sep 27 in C# by krishna
• 2,820 points
22 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
0 answers

How to do a LIKE query with linq

How can I use Linq to conduct ...READ MORE

Jun 11 in C# by pranav
• 2,580 points
35 views
0 votes
0 answers

oops concept query

This is my oops question. This is my ...READ MORE

Jun 11 in C# by jyoti
• 1,240 points
41 views
0 votes
1 answer

Examples of dynamic polymorphism in c#

Check the example of polymorphism below. We ...READ MORE

answered Jun 7 in C# by pranav
• 2,580 points
128 views
0 votes
1 answer

Object Oriented Programming Basic Concept(C#)

Use this link https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers protected internal: The type or ...READ MORE

answered Jun 17 in C# by jyoti
• 1,240 points
45 views
0 votes
0 answers

How to force overriding a method in a descendant, without having an abstract base class

This is my code using System; using System.Collections.Generic; using System.Linq; using ...READ MORE

Jun 11 in C# by krishna
• 2,820 points
105 views
0 votes
3 answers

Explain OOPs concept in python with programatic examples

Understanding OOPs is a gradual process and ...READ MORE

answered Nov 24, 2020 in Python by William
• 140 points
928 views
+1 vote
1 answer

R query and Data Science

Dear Deepika, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
277 views
0 votes
1 answer

How Impala is fast compared to Hive in terms of query response?

Impala provides faster response as it uses MPP(massively ...READ MORE

answered Mar 21, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
1,278 views
+16 votes
4 answers
0 votes
1 answer

MDX query in Tableau pivot table

You can view them here - \My Documents\My ...READ MORE

answered Apr 6, 2018 in Tableau by QueenBee
• 1,820 points
445 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP