c# - The Namespace X already contains a definition for XX? -


i don't understand error getting. have tried clean , build project several times. can me? program.cs

using system; using system.collections.generic; using system.net.networkinformation; using system.net.sockets; using system.io; using system.threading.tasks;  namespace httprequestapp {     class program     {         static void main(string[] args)         {             var lstwebsites = new list<string>             {                 "www.mearstransportation.com",                 "www.amazon.com",                 "www.ebay.com",                 "www.att.com",                 "www.verizon.com",                 "www.sprint.com",                 "www.centurylink.com",                 "www.yahoo.com"             };             string filename = @"requestlog.txt";             {                 using (var writer = new streamwriter(filename, true))                 {                     foreach (string website in lstwebsites)                     {                         (var = 0; < 4; i++)                         {                             mywebrequest request = new mywebrequest();                             request.request(website);                         }                     }                 }             }         }     } } 

mywebrequest.cs - problem here: public class mywebrequest error is: "the namespace httprequestapp contains definition mywebrequest"

using httprequestapp.mywebrequest; using system; using system.collections.generic; using system.io; using system.net.networkinformation; using system.net.sockets; using system.threading.tasks;  namespace httprequestapp {     public class mywebrequest : iwebrequest     {         public void request(string strwebsite)         {             list<string> lstwebsites = program.getlist(strwebsite);             using (var client2 = new tcpclient(strwebsite, 80))             {                 using (networkstream stream = client2.getstream())                 using (streamwriter writer = new streamwriter(stream))                 using (streamreader reader2 = new streamreader(stream))                 {                     //writer.autoflush = true;                     writer.writeline("get / http/1.1");                     writer.writeline("host: {0}:80", lstwebsites[1]);                     writer.writeline("connection: close");                     writer.writeline();                     writer.writeline();                      string theresponse = reader2.readtoend();                     console.writeline(theresponse);                 }             }         }     } } 

iwebrequest.cs

using system; using system.collections.generic; using system.linq; using system.text; //using system.io; using system.threading.tasks; //using mywebrequest.lib;  namespace httprequestapp.mywebrequest {     public interface iwebrequest     {         task<list<strwebsite>> getlist();         void request();     } } 

to give on view of trying accomplish here is: send http request initial page. http response , check 200 response code. , time how long took retrieve response. console app need not have depend on console, needs independent application can use somewhere else. if has suggestions on how can simplify code please let me know. thanks.

you have httprequestapp.mywebrequest namespace , httprequestapp.mywebrequest class name: c# compiler confused (and human too...)

consider renaming namespace in such httprequestapp.mywebrequestnamespace if want different namespace.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -