Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

 
AnswerRe: Rx - Reactive Extensions Pin
Meshack Musundi12-Jul-17 10:45
professionalMeshack Musundi12-Jul-17 10:45 
AnswerRe: Rx - Reactive Extensions Pin
Kenneth Haugland13-Jul-17 13:13
mvaKenneth Haugland13-Jul-17 13:13 
AnswerRe: Rx - Reactive Extensions Pin
jschell15-Jul-17 7:41
jschell15-Jul-17 7:41 
Questionplaying media from server storage help.. in C# Pin
AnthonyRaven11-Jul-17 17:10
AnthonyRaven11-Jul-17 17:10 
AnswerRe: playing media from server storage help.. in C# Pin
Richard MacCutchan11-Jul-17 21:42
mveRichard MacCutchan11-Jul-17 21:42 
QuestionRfid Reader Tag number Extraction Pin
Member 132923109-Jul-17 4:18
Member 132923109-Jul-17 4:18 
AnswerRe: Rfid Reader Tag number Extraction Pin
Michael_Davies9-Jul-17 4:40
Michael_Davies9-Jul-17 4:40 
QuestionWhy can't I access a variable declared in derived class with the object of base class Pin
Member 132999538-Jul-17 7:02
Member 132999538-Jul-17 7:02 
Hi, Good Evening everyone

I have created two classes namely Shape, Rectangle with Draw() method in both the classes, Rectangle class is a deried class from Shape. I have declared a public variable in Rectangle called num and initialised a value to it.

In the main class I have created an object of type class in following manner.

Shape s = new Rectangle();

Now when I am trying to access num variable of rectangle class it gives error saying “ /Users/apple/Projects/Practice/Practice/Program.cs(33,33): Error CS1061: 'Shape' does not contain a definition for 'num' and no extension method 'num' accepting a first argument of type 'Shape' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Practice)”

My Understanding : The statement new Rectangle(); creates an object of type Rectangle in the memory and its reference is stored in object s of type Shape. So the object s should have access to variable num defined in rectangle class. Please make me understand this concept why we can’t access num variable from Object of type Shape.

Pls find the attached screenshot.

modified 8-Jul-17 13:10pm.

AnswerRe: Why can't I access a variable declared in derived class with the object of base class Pin
PIEBALDconsult8-Jul-17 7:10
mvePIEBALDconsult8-Jul-17 7:10 
AnswerRe: Why can't I access a variable declared in derived class with the object of base class Pin
Dave Kreskowiak8-Jul-17 7:27
mveDave Kreskowiak8-Jul-17 7:27 
AnswerRe: Why can't I access a variable declared in derived class with the object of base class Pin
OriginalGriff8-Jul-17 19:07
mveOriginalGriff8-Jul-17 19:07 
AnswerRe: Why can't I access a variable declared in derived class with the object of base class Pin
BillWoodruff9-Jul-17 23:02
professionalBillWoodruff9-Jul-17 23:02 
AnswerRe: Why can't I access a variable declared in derived class with the object of base class Pin
Gerry Schmitz11-Jul-17 6:48
mveGerry Schmitz11-Jul-17 6:48 
SuggestionRe: Why can't I access a variable declared in derived class with the object of base class Pin
Richard Deeming11-Jul-17 7:01
mveRichard Deeming11-Jul-17 7:01 
Questionprinter default font. Pin
rahul19957-Jul-17 1:53
rahul19957-Jul-17 1:53 
AnswerRe: printer default font. Pin
Dave Kreskowiak7-Jul-17 2:25
mveDave Kreskowiak7-Jul-17 2:25 
AnswerRe: printer default font. Pin
Pete O'Hanlon7-Jul-17 2:53
mvePete O'Hanlon7-Jul-17 2:53 
GeneralRe: printer default font. Pin
OriginalGriff7-Jul-17 4:11
mveOriginalGriff7-Jul-17 4:11 
GeneralRe: printer default font. Pin
Richard MacCutchan7-Jul-17 4:22
mveRichard MacCutchan7-Jul-17 4:22 
GeneralRe: printer default font. Pin
OriginalGriff7-Jul-17 4:30
mveOriginalGriff7-Jul-17 4:30 
GeneralRe: printer default font. Pin
Richard MacCutchan7-Jul-17 5:19
mveRichard MacCutchan7-Jul-17 5:19 
AnswerRe: printer default font. Pin
Richard Andrew x647-Jul-17 7:41
professionalRichard Andrew x647-Jul-17 7:41 
GeneralRe: printer default font. Pin
rahul19959-Jul-17 18:48
rahul19959-Jul-17 18:48 
AnswerRe: printer default font. Pin
jschell10-Jul-17 4:39
jschell10-Jul-17 4:39 
GeneralRe: printer default font. Pin
rahul199510-Jul-17 19:02
rahul199510-Jul-17 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.