Jump to content
  • Advertisement
Sign in to follow this  
JohnnyCode

C# - instantiating an object

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,
I do not get one thing in C# and it seems total enigma to me. There are clasess in framework of .NET that contains only getter propreties and some methods which all do not alter inner data of the class. Example of such classes are many, for example System.Web.UI.Page class. But how can such object get instantieted and recieve data to itself?
An external function that gets a parameter or returns this object? But how the instructions in external function actualy do that if class is all private and has no functions to manipulate its data?

Share this post


Link to post
Share on other sites
Advertisement

System.Web.UI.Page's members aren't mostly private, they are mostly protected. This is a class that's designed with some safe defaults who's behavior can be modified by inheritance. Each .aspx file creates a new class derived from Page possibly combined with additional code.


Thanks much. But inheritance is not always the case. For example sealed class HttpRequest. It has only Getters and 6 functions. It derives from object class right away. I do not see how possibly it can get data in , for example, its headers collection and so on. The constructor involves only few parameters from which this information can not be extracted.

Share this post


Link to post
Share on other sites
System.Web.HttpRequest, in addition to the public constructor, has two internal constructors. One of these constructors accepts a HttpWorkerRequest object which contains information about the headers. You can find out this kind of information by using Reflector.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!