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

C#

 
AnswerRe: Connection timeout Pin
Roger Wright30-May-10 23:19
professionalRoger Wright30-May-10 23:19 
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 
In the following code, which I have found to be common practice amongst the examples I have found on the web, the WebRequest class is instantiated like it's a regular class yet it's an abstract class. Underneath the hood, the http object is a really a HttpWebRequest object, but doesn't this defy the principle that you cannot instantiate abstract classes through it's syntax? This is the line that doesn't make sense to me: WebRequest http = WebRequest.Create(url);. WebRequest (abstract class) is being instantiated as object http. If the underlying class that is being instantiated is the HttpWebRequest than shouldn't that only be allowed?? such as HttpWebRequest http = HttpWebRequest.Create(url)?

class ScanUrl
{
    /// <summary>
    /// Scan the URL and display headers.
    /// </summary>
    /// <param name="u">The URL to scan.</param>
    public StringBuilder Scan(String u)
    {
        StringBuilder sb = new StringBuilder();
        Uri url = new Uri(u);
        WebRequest http = WebRequest.Create(url);
        WebResponse response = http.GetResponse();

        int count = 0;
        String key, value;

        for (count = 0; count < response.Headers.Keys.Count; count++)
        {
            key = response.Headers.Keys[count];
            value = response.Headers[key];

            if (value != null)
            {
                if (key == null)
                    sb.Append(value + "\n");
                else
                    sb.Append(key + ": " + value + "\n");
            }
        }
        return sb;
    }
}

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 
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 

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.