Resolved How To Override The Runtime System.dll Namespace?

Dalski

Active member
Joined
Jun 3, 2020
Messages
40
Programming Experience
Beginner
I'm trying to understand inheritance fully Inheritance - C# Programming Guide but it'd be better if I could put the object class in the actual tutorial. I want to fully absorb it by stepping through the code & see the Object class working. The tutorial only has the derived classes WorkItem & ChangeRequest & their members. It'd be so much better if I could see the object class working as I step-through.

1 - Is it possible to find the source code of the object class? I found the System.dll in virtual studio, but this looks to be object code, already compiled (I think I'm correct in this statement?).

2 - If I was to complete 1, would I then run into naming conflicts or would C# prioritize local declarations over namespaced ones?
 
object is a built-in C# type that is the base of all classes, it is represented by System.Object class. Object Class (System)
As open-source it can be viewed here at Reference Source - but this is also something I think most people would never read.
You don't declare this in local code, and you rarely use it at all. Notice in code example you don't actually write code to inherit Object class. The code example should be fully functional to copy and use as is.
 
It'd be so much better if I could see the object class working as I step-through.
No it wouldn't. I've never once looked at the source for the Object class and only rarely done so for other Framework classes. Seeing the code in the Object class execute is not going to help you understand inheritance. I think that the best way to understand the basic principles of inheritance is to consider classification of animals. You could consider the Animal class to be the base class for all animals, just as the Object class is the base class for all .NET objects. Within the Animal kingdom, each phylum has all the characteristics of Animal plus adds more of its own. Each class has all the characteristics of its phylum plus adds more of its own. Each order extends its class, each family extends its order, each genus extends its family and each species extends its genus. Just as a human is a primate, is a mammal, ..., is an animal, so a Button is a ButtonBase, is a Control, is a Component, ..., is an Object. Simples.
 
Just like seeing the underlying v-tables in C++ won't help a C++ programmer understand inheritance or polymorphism. It could help a C or Assembly programmer understand how to implement their poor man's version of inheritance and polymorphism, but it still won't necessarily help them understand the concept itself. It's like watching the beads on an abacus being moved around, but it takes understanding the concept of digit places to make things work.
 
Thanks guys, yeah I get that it's part of the system. Ok so I'm pretty happy with my understanding of inheritance, covariance & contravariance.

My title wasn't the best, my apologies to the forum.

JohnH many thanks for the link there & JM many thanks for your kind explanations, it's strange in the reference runtime does not display the object class. It lists ComTypes, WindowsRuntime & others but the object class is not there. So it seems that the .NET reference is a strange old thing & a bit misleading from a C# perspective. Been getting on great with the C# microsoft search results, but microsoft is not showing much on the system namespace and resulting object class.
 
Last edited:
it's strange in the reference runtime does not display the object class. It lists ComTypes, WindowsRuntime & others but the object class is not there. So it seems that the .NET reference is a strange old thing & a bit misleading from a C# perspective. Been getting on great with the C# microsoft search results, but microsoft is not showing much on the system namespace and resulting object class.
That link appears to be for the System.dll assembly. Assemblies and namespaces are not the same thing. Each assembly can contain types that are members of multiple namespaces and each namespace can have types declared in multiple assemblies. If you select the Namespaces tab and expand the nodes, you can see that loads of namespaces have types declared in System.dll. If you go to the Project tab, you'll see what would basically be the Solution Explorer for the project that builds that assembly. If you expand the References node, you'll see the mscorlib.dll assembly. Click that and it will switch to that assembly. Select the Namespaces tab and the expand the System node and you'll see the Object class listed, under the appropriate namespace, in the appropriate assembly.
 
Thanks for the detailed explanation jm; very helpful. This Reference Source is golddust & exactly what I'm after! I've had a good dig through the Microsoft.NET Reference Source now. Following on from what you've said; and please do not mistake my comments below as criticism. I greatly appreciate that you good people are taking time out of your busy days to help someone you don't know at all find his path on his coding journey with absolutely no benefit to yourselves whatsoever. My comments below is merely myself trying to understand the Reference Source; as once I understand this, I'll be well on my way I think. I have multi-quoted below as it makes it much clearer to address individual key issues:

That link appears to be for the System.dll assembly.

I can't see any breadcrumbs showing this; to my little brain it looks like the root page of the .NET Framework?

If you select the Namespaces tab and expand the nodes, you can see that loads of namespaces have types declared in System.dll.

1593511224352.png



The Reference Source makes it look like it references a System namespace only, with no indication to what "assembly" it's coming from? I know there is a System.dll assembly, but how would a beginner be aware of this from the Reference Source? I think you mean Project > System; then we'd be in the .system assembly right?

1593512211857.png


If you go to the Project tab, you'll see what would basically be the Solution Explorer for the project that builds that assembly. If you expand the References node, you'll see the mscorlib.dll assembly. Click that and it will switch to that assembly. Select the Namespaces tab and the expand the System node and you'll see the Object class listed, under the appropriate namespace, in the appropriate assembly.

Sorry I can't see a mscorlib.dll assembly listed at all; I see a .csproj with that prefix but not a .dll:

 
1593513695418.png
 
I know there is a System.dll assembly, but how would a beginner be aware of this from the Reference Source?
Reference source is not general reading material. It is something that is available for people that have special interest far outside learning C#, .Net and the available frameworks. As a beginner you should concentrate on general learning material and use .NET API browser to read documentation for types and members that you want to learn more about.
 
Thanks John but I don't think it's greatly complicated. All I need to know is the lingo, a few key points. I'm not an absolute beginner. I've dabbled with HTML, CSS & VBA. Completed the entire learncpp.com website (that is a good tutorial site, far better than tutorialsteacher on C#) and referenced the cppreference.com reference in the past out of interest. I've dabbled with Raspberry Pi's in the past too, altering system commands in the etc directory & a plethora of industry specific apps.

I'm not just interested in C#, I am interested in computers overall. If truth be told I greatly preferred C++ compared to C#, but I have a goal in mind & the GUI is going to be much easier in C#.


EDIT - Sorry I didn't notice your double post. At what timestamp did you get that from my video? I've watched it several times over & haven't seen that spot; I see a point where the .proj appears, but nothing in the video like that. Maybe I'm going a bit cross-eyed on this topic, but it is a fundamental principle I think.
 
Last edited:
I have a goal in mind & the GUI is going to be much easier in C#.
C++ is only a lower level language. I don't share the sentiment of how it would be easier do develop a UI based on either language alone. As JohnH and myself have already alluded to the path for you to start learning C#, maybe you should start there. Your experience with the web based languages won't help you in C#. Perhaps maybe it will a little within Xaml, but don't bring your experiences from C/Raspberry PI to C#. This is what I advise, as I program in all of those languages you mentioned. What you need to understand is that C# is for the big boys; as its considered a Enterprise level coding language. And I agree with JohnH, that you don't need to go looking at the references just yet, as they are really for more experienced developers who need to know the functions and usage of types etc in a particular reference. Stick with the link linked by JohnH above for getting by.
 
Let me put this way. When you were learning C++ and you saw this code to learn about variables and getting input from the user:
C++:
int value;
cin >> value;
Did you immediately stop your study of variables on pause, and try to go down the rabbit hole of how does the >> operator work? How did operator overloads work? How do istream's work? How does parsing work? Did you crack open the C++ and C library source code to learn that concept of variables and getting input?

Or did you just accept the high level explanation that what is happening is that input is parsed from the standard input stream, and stored into the variable?
 
Thanks for your input Sheepings. Agree completely, I am a feeble one atm. I'm like the skinny kid at the gym trying to lift huge weights. But I have to keep trying. I don't want to go raising threads on every command I'm curious about & deep down I don't think you do either. To quote your signature “A language that doesn't affect the way you think about programming is not worth knowing.” ~ Alan J. Perlis.

Apologies as I haven't made this the most direct question in the world, but in my defence there has been some contradictory info in this thread. I've referenced the links given to me only to be told the links are incorrect by other users in the same thread :p & if one reads the thread there is contradictory info. I started to write it out post by post but didn't want to seem ungrateful so I won't post it ;).
 
Let me put this way. When you were learning C++ and you saw this code to learn about variables and getting input from the user:
C++:
int value;
cin >> value;
Did you immediately stop your study of variables on pause, and try to go down the rabbit hole of how does the >> operator work? How did operator overloads work? How do istream's work? How does parsing work? Did you crack open the C++ and C library source code to learn that concept of variables and getting input?

Or did you just accept the high level explanation that what is happening is that input is parsed from the standard input stream, and stored into the variable?


Erm if I'm being honest I did look into how memory is stored, going into the stack & the heap, then looking int assembly a little, with push, pop etc... Iteration stacks... I think I even did read up on comparisson operators assessing l-values & r-values.
Then reading up on how pdfs are stored with image maps, & how pdfs store glyphs. Trying to get to sleep but unable to sleep thinking about it, getting up in the middle of the night to read more. Reading autocad's developers document on it's filetype, the hierarchical structure of entities drawn in CAD. Don't get me wrong I'm not understanding all of it to the level you guys would, but I'm suffering of being interested in everything.
It's a disease, don't judge me :LOL:.
 
Back
Top Bottom