Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
QuestionC# to excel Pin
prithaa30-May-10 20:06
prithaa30-May-10 20:06 
AnswerRe: C# to excel Pin
Abhinav S30-May-10 20:25
Abhinav S30-May-10 20:25 
GeneralRe: C# to excel Pin
prithaa30-May-10 20:28
prithaa30-May-10 20:28 
AnswerRe: C# to excel Pin
Abhinav S30-May-10 20:38
Abhinav S30-May-10 20:38 
AnswerRe: C# to excel Pin
J. Dunlap30-May-10 20:28
J. Dunlap30-May-10 20:28 
GeneralRe: C# to excel Pin
prithaa31-May-10 0:26
prithaa31-May-10 0:26 
QuestionThe WebRequest class is abstract, so how are we able to instantiate an object from it? Pin
Jeff Kissinger30-May-10 11:10
Jeff Kissinger30-May-10 11:10 
AnswerRe: The WebRequest class is abstract, so how are we able to instantiate an object from it? Pin
Dave Kreskowiak30-May-10 11:50
mveDave Kreskowiak30-May-10 11:50 
Jeff Kissinger wrote:
the WebRequest class is instantiated like it's a regular class


Not, it's not. The WebRequest class exposes a static method (no instance required!) that creates an instance of HttpWebRequest, which inherits from WebRequest. Since the returned object inherits from WebRequest, you can use the WebRequest methods and properties since they are implemented by the HttpWebRequest class.

Jeff Kissinger wrote:
but doesn't this defy the principle that you cannot instantiate abstract classes through it's syntax


No, since you're not instantiating the WebRequest class. Your instantiating an implementor of it, namely HttpWebRequest.

Jeff Kissinger wrote:
If the underlying class that is being instantiated is the HttpWebRequest than shouldn't that only be allowed??


Read up on inheritance. You can treat the returned object as any type in its inheritance chain, all the way up to System.Object. The interitance chain for HttpWebRequest is:
System.Object
   System.MarshalByRefObject
      System.Net.WebRequest
         System.Net.HttpWebRequest


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008
But no longer in 2009...




AnswerRe: The WebRequest class is abstract, so how are we able to instantiate an object from it? Pin
PIEBALDconsult30-May-10 17:34
mvePIEBALDconsult30-May-10 17:34 
AnswerRe: The WebRequest class is abstract, so how are we able to instantiate an object from it? Pin
Jeff Kissinger31-May-10 10:05
Jeff Kissinger31-May-10 10:05 
QuestionBlocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 7:40
Hamed Musavi30-May-10 7:40 
AnswerRe: Blocking vs. Non-Blocking Socket efficiency? Pin
PIEBALDconsult30-May-10 8:12
mvePIEBALDconsult30-May-10 8:12 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 8:17
Hamed Musavi30-May-10 8:17 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
PIEBALDconsult30-May-10 16:19
mvePIEBALDconsult30-May-10 16:19 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 8:53
Hamed Musavi30-May-10 8:53 
AnswerRe: Blocking vs. Non-Blocking Socket efficiency? Pin
harold aptroot30-May-10 9:00
harold aptroot30-May-10 9:00 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 9:02
Hamed Musavi30-May-10 9:02 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
harold aptroot30-May-10 9:13
harold aptroot30-May-10 9:13 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
harold aptroot30-May-10 9:26
harold aptroot30-May-10 9:26 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 9:28
Hamed Musavi30-May-10 9:28 
AnswerRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Luc Pattyn30-May-10 10:23
sitebuilderLuc Pattyn30-May-10 10:23 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Hamed Musavi30-May-10 18:25
Hamed Musavi30-May-10 18:25 
GeneralRe: Blocking vs. Non-Blocking Socket efficiency? Pin
Luc Pattyn31-May-10 1:48
sitebuilderLuc Pattyn31-May-10 1:48 
QuestionUnix Time Pin
jojoba201130-May-10 7:39
jojoba201130-May-10 7:39 
AnswerRe: Unix Time Pin
PIEBALDconsult30-May-10 8:34
mvePIEBALDconsult30-May-10 8:34 

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.