none
Why doesn't this code compile?

    Question

  • Let's start with a simplified version because it does compile and runs fine:

       private sealed class objDataTable: DataTable {
                  public objDataTable() { }
                  public void DoNothing() {
                    MessageBox.Show("Hello world");
                }
            }
    
    
      objDataTable dTable = new objDataTable();
      dTable.DoNothing();

    But in the longer version - which seems to be the same structure - the method doesn't show in Intellisense (as though it were private instead of public), in VS 2008.

    objDataTableGecode dResponse = new objDataTableGecode(); //Next line doesn't compile. dResponse.readResponseFile("C:\\fil.txt"); //method not showing in Intellisens!

    Ok I'm a dork, I must be missing something obvious here. What is it? private sealed class objDataTableGecode : DataTable { public void readResponseFile(string pathToFile) { string[] lines = File.ReadAllLines(pathToFile); for (int i = 1; i < lines.Length; i++) { string line = lines[i]; string[] words = line.Split('|'); DataRow r = this.NewRow(); this.Rows.Add(r); for (int w = 0; w < words.Length; w++) r[w] = words[w]; } } public DataColumn dcId; public DataColumn dcRequestCulture; public DataColumn dcRequestQuery; public DataColumn dcRequestAddressLine; public DataColumn dcRequestAdminDistrict; public DataColumn dcRequestCountryRegion; public DataColumn dcRequestAdminDistrict2; public DataColumn dcRequestFormattedAddress; public DataColumn dcRequestLocality; public DataColumn dcRequestPostalCode; public DataColumn dcRequestPostalTown; public DataColumn dcRequestConfidenceFilterMinimumConfidence; public DataColumn dcReverseRequestIncludeEntityTypes; public DataColumn dcReverseRequestLocationLatitude; public DataColumn dcReverseRequestLocationLongitude; public DataColumn dcResponseAddressLine; public DataColumn dcResponseAdminDistrict; public DataColumn dcResponseCountryRegion; public DataColumn dcResponseAdminDistrict2; public DataColumn dcResponseFormattedAddress; public DataColumn dcResponseLocality; public DataColumn dcResponsePostalCode; public DataColumn dcResponsePostalTown; public DataColumn dcResponseNeighborhood; public DataColumn dcResponseLandmark; public DataColumn dcResponseConfidence; public DataColumn dcResponseName; public DataColumn dcResponseEntityType; public DataColumn dcResponseMatchCodes; public DataColumn dcResponsePointLatitude; public DataColumn dcResponsePointLongitude; public DataColumn dcResponseBoundingBoxEastLongitude; public DataColumn dcResponseBoundingBoxNorthLatitude; public DataColumn dcResponseBoundingBoxWestLongitude; public DataColumn dcResponseBoundingBoxSouthLatitude; public DataColumn dcResponseQueryParseValues; public DataColumn dcResponsePoints; public DataColumn dcStatusCode; public DataColumn dcFaultReason; public DataColumn dcTraceId; public objDataTableGecode() { dcId = this.Columns.Add("Id", typeof(string)); dcRequestCulture = this.Columns.Add("GeocodeRequest/Culture", typeof(string)); dcRequestQuery = this.Columns.Add("GeocodeRequest/Query", typeof(string)); dcRequestAddressLine = this.Columns.Add("GeocodeRequest/Address/AddressLine", typeof(string)); dcRequestAdminDistrict = this.Columns.Add("GeocodeRequest/Address/AdminDistrict", typeof(string)); dcRequestCountryRegion = this.Columns.Add("GeocodeRequest/Address/CountryRegion", typeof(string)); dcRequestAdminDistrict2 = this.Columns.Add("GeocodeRequest/Address/AdminDistrict2", typeof(string)); dcRequestFormattedAddress = this.Columns.Add("GeocodeRequest/Address/FormattedAddress", typeof(string)); dcRequestLocality = this.Columns.Add("GeocodeRequest/Address/Locality", typeof(string)); dcRequestPostalCode = this.Columns.Add("GeocodeRequest/Address/PostalCode", typeof(string)); dcRequestPostalTown = this.Columns.Add("GeocodeRequest/Address/PostalTown", typeof(string)); dcRequestConfidenceFilterMinimumConfidence = this.Columns.Add("GeocodeRequest/ConfidenceFilter/MinimumConfidence", typeof(string)); dcReverseRequestIncludeEntityTypes = this.Columns.Add("ReverseGeocodeRequest/IncludeEntityTypes", typeof(string)); dcReverseRequestLocationLatitude = this.Columns.Add("ReverseGeocodeRequest/Location/Latitude", typeof(string)); dcReverseRequestLocationLongitude = this.Columns.Add("ReverseGeocodeRequest/Location/Longitude", typeof(string)); dcResponseAddressLine = this.Columns.Add("GeocodeResponse/Address/AddressLine", typeof(string)); dcResponseAdminDistrict = this.Columns.Add("GeocodeResponse/Address/AdminDistrict", typeof(string)); dcResponseCountryRegion = this.Columns.Add("GeocodeResponse/Address/CountryRegion", typeof(string)); dcResponseAdminDistrict2 = this.Columns.Add("GeocodeResponse/Address/AdminDistrict2", typeof(string)); dcResponseFormattedAddress = this.Columns.Add("GeocodeResponse/Address/FormattedAddress", typeof(string)); dcResponseLocality = this.Columns.Add("GeocodeResponse/Address/Locality", typeof(string)); dcResponsePostalCode = this.Columns.Add("GeocodeResponse/Address/PostalCode", typeof(string)); dcResponsePostalTown = this.Columns.Add("GeocodeResponse/Address/PostalTown", typeof(string)); dcResponseNeighborhood = this.Columns.Add("GeocodeResponse/Address/Neighborhood", typeof(string)); dcResponseLandmark = this.Columns.Add("GeocodeResponse/Address/Landmark", typeof(string)); dcResponseConfidence = this.Columns.Add("GeocodeResponse/Confidence", typeof(string)); dcResponseName = this.Columns.Add("GeocodeResponse/Name", typeof(string)); dcResponseEntityType = this.Columns.Add("GeocodeResponse/EntityType", typeof(string)); dcResponseMatchCodes = this.Columns.Add("GeocodeResponse/MatchCodes", typeof(string)); dcResponsePointLatitude = this.Columns.Add("GeocodeResponse/Point/Latitude", typeof(string)); dcResponsePointLongitude = this.Columns.Add("GeocodeResponse/Point/Longitude", typeof(string)); dcResponseBoundingBoxEastLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/EastLongitude", typeof(string)); dcResponseBoundingBoxNorthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/NorthLatitude", typeof(string)); dcResponseBoundingBoxWestLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/WestLongitude", typeof(string)); dcResponseBoundingBoxSouthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/SouthLatitude", typeof(string)); dcResponseQueryParseValues = this.Columns.Add("GeocodeResponse/QueryParseValues", typeof(string)); dcResponsePoints = this.Columns.Add("GeocodeResponse/GeocodePoints", typeof(string)); dcStatusCode = this.Columns.Add("StatusCode", typeof(string)); dcFaultReason = this.Columns.Add("FaultReason", typeof(string)); dcTraceId = this.Columns.Add("TraceId", typeof(string)); foreach (DataColumn dc in this.Columns) dc.DefaultValue = string.Empty; } }



    • Edited by jal2 Thursday, December 26, 2013 12:42 PM
    Thursday, December 26, 2013 12:36 PM

Answers

  • I didn't do anything except put the code into a new project and I'm not getting any errors.  I added to libraries to the top of the module (Data and IO)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.IO;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                objDataTableGecode dResponse = new objDataTableGecode();
    
                dResponse.readResponseFile("C:\\fil.txt"); //method not showing in Intellisens!
    
    
            }
            private sealed class objDataTableGecode : DataTable
            {
                public void readResponseFile(string pathToFile)
                {
                    string[] lines = File.ReadAllLines(pathToFile);
                    for (int i = 1; i < lines.Length; i++)
                    {
                        string line = lines[i];
                        string[] words = line.Split('|');
                        DataRow r = this.NewRow();
                        this.Rows.Add(r);
                        for (int w = 0; w < words.Length; w++) r[w] = words[w];
                    }
                }
                public DataColumn dcId;
                public DataColumn dcRequestCulture;
                public DataColumn dcRequestQuery;
                public DataColumn dcRequestAddressLine;
                public DataColumn dcRequestAdminDistrict;
                public DataColumn dcRequestCountryRegion;
                public DataColumn dcRequestAdminDistrict2;
                public DataColumn dcRequestFormattedAddress;
                public DataColumn dcRequestLocality;
                public DataColumn dcRequestPostalCode;
                public DataColumn dcRequestPostalTown;
                public DataColumn dcRequestConfidenceFilterMinimumConfidence;
                public DataColumn dcReverseRequestIncludeEntityTypes;
                public DataColumn dcReverseRequestLocationLatitude;
                public DataColumn dcReverseRequestLocationLongitude;
                public DataColumn dcResponseAddressLine;
                public DataColumn dcResponseAdminDistrict;
                public DataColumn dcResponseCountryRegion;
                public DataColumn dcResponseAdminDistrict2;
                public DataColumn dcResponseFormattedAddress;
                public DataColumn dcResponseLocality;
                public DataColumn dcResponsePostalCode;
                public DataColumn dcResponsePostalTown;
                public DataColumn dcResponseNeighborhood;
                public DataColumn dcResponseLandmark;
                public DataColumn dcResponseConfidence;
                public DataColumn dcResponseName;
                public DataColumn dcResponseEntityType;
                public DataColumn dcResponseMatchCodes;
                public DataColumn dcResponsePointLatitude;
                public DataColumn dcResponsePointLongitude;
                public DataColumn dcResponseBoundingBoxEastLongitude;
                public DataColumn dcResponseBoundingBoxNorthLatitude;
                public DataColumn dcResponseBoundingBoxWestLongitude;
                public DataColumn dcResponseBoundingBoxSouthLatitude;
                public DataColumn dcResponseQueryParseValues;
                public DataColumn dcResponsePoints;
                public DataColumn dcStatusCode;
                public DataColumn dcFaultReason;
                public DataColumn dcTraceId;
                public objDataTableGecode()
                {
                    dcId = this.Columns.Add("Id", typeof(string));
                    dcRequestCulture = this.Columns.Add("GeocodeRequest/Culture", typeof(string));
                    dcRequestQuery = this.Columns.Add("GeocodeRequest/Query", typeof(string));
                    dcRequestAddressLine = this.Columns.Add("GeocodeRequest/Address/AddressLine", typeof(string));
                    dcRequestAdminDistrict = this.Columns.Add("GeocodeRequest/Address/AdminDistrict", typeof(string));
                    dcRequestCountryRegion = this.Columns.Add("GeocodeRequest/Address/CountryRegion", typeof(string));
                    dcRequestAdminDistrict2 = this.Columns.Add("GeocodeRequest/Address/AdminDistrict2", typeof(string));
                    dcRequestFormattedAddress = this.Columns.Add("GeocodeRequest/Address/FormattedAddress", typeof(string));
                    dcRequestLocality = this.Columns.Add("GeocodeRequest/Address/Locality", typeof(string));
                    dcRequestPostalCode = this.Columns.Add("GeocodeRequest/Address/PostalCode", typeof(string));
                    dcRequestPostalTown = this.Columns.Add("GeocodeRequest/Address/PostalTown", typeof(string));
                    dcRequestConfidenceFilterMinimumConfidence = this.Columns.Add("GeocodeRequest/ConfidenceFilter/MinimumConfidence", typeof(string));
                    dcReverseRequestIncludeEntityTypes = this.Columns.Add("ReverseGeocodeRequest/IncludeEntityTypes", typeof(string));
                    dcReverseRequestLocationLatitude = this.Columns.Add("ReverseGeocodeRequest/Location/Latitude", typeof(string));
                    dcReverseRequestLocationLongitude = this.Columns.Add("ReverseGeocodeRequest/Location/Longitude", typeof(string));
                    dcResponseAddressLine = this.Columns.Add("GeocodeResponse/Address/AddressLine", typeof(string));
                    dcResponseAdminDistrict = this.Columns.Add("GeocodeResponse/Address/AdminDistrict", typeof(string));
                    dcResponseCountryRegion = this.Columns.Add("GeocodeResponse/Address/CountryRegion", typeof(string));
                    dcResponseAdminDistrict2 = this.Columns.Add("GeocodeResponse/Address/AdminDistrict2", typeof(string));
                    dcResponseFormattedAddress = this.Columns.Add("GeocodeResponse/Address/FormattedAddress", typeof(string));
                    dcResponseLocality = this.Columns.Add("GeocodeResponse/Address/Locality", typeof(string));
                    dcResponsePostalCode = this.Columns.Add("GeocodeResponse/Address/PostalCode", typeof(string));
                    dcResponsePostalTown = this.Columns.Add("GeocodeResponse/Address/PostalTown", typeof(string));
                    dcResponseNeighborhood = this.Columns.Add("GeocodeResponse/Address/Neighborhood", typeof(string));
                    dcResponseLandmark = this.Columns.Add("GeocodeResponse/Address/Landmark", typeof(string));
                    dcResponseConfidence = this.Columns.Add("GeocodeResponse/Confidence", typeof(string));
                    dcResponseName = this.Columns.Add("GeocodeResponse/Name", typeof(string));
                    dcResponseEntityType = this.Columns.Add("GeocodeResponse/EntityType", typeof(string));
                    dcResponseMatchCodes = this.Columns.Add("GeocodeResponse/MatchCodes", typeof(string));
                    dcResponsePointLatitude = this.Columns.Add("GeocodeResponse/Point/Latitude", typeof(string));
                    dcResponsePointLongitude = this.Columns.Add("GeocodeResponse/Point/Longitude", typeof(string));
                    dcResponseBoundingBoxEastLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/EastLongitude", typeof(string));
                    dcResponseBoundingBoxNorthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/NorthLatitude", typeof(string));
                    dcResponseBoundingBoxWestLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/WestLongitude", typeof(string));
                    dcResponseBoundingBoxSouthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/SouthLatitude", typeof(string));
                    dcResponseQueryParseValues = this.Columns.Add("GeocodeResponse/QueryParseValues", typeof(string));
                    dcResponsePoints = this.Columns.Add("GeocodeResponse/GeocodePoints", typeof(string));
                    dcStatusCode = this.Columns.Add("StatusCode", typeof(string));
                    dcFaultReason = this.Columns.Add("FaultReason", typeof(string));
                    dcTraceId = this.Columns.Add("TraceId", typeof(string));
                    foreach (DataColumn dc in this.Columns) dc.DefaultValue = string.Empty;
                }
    
            }
        }
        
    }
    

    • Edited by Joel Engineer Thursday, December 26, 2013 1:20 PM
    • Marked as answer by jal2 Friday, December 27, 2013 8:58 AM
    Thursday, December 26, 2013 1:16 PM

All replies

  • Woops I forgot to insert the filename - but it still won't compile, won't show in Intellisense:

     dResponse.readResponseFile("C:\\fil.txt");

    I'll edit the original.

    Thursday, December 26, 2013 12:42 PM
  • I didn't do anything except put the code into a new project and I'm not getting any errors.  I added to libraries to the top of the module (Data and IO)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.IO;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                objDataTableGecode dResponse = new objDataTableGecode();
    
                dResponse.readResponseFile("C:\\fil.txt"); //method not showing in Intellisens!
    
    
            }
            private sealed class objDataTableGecode : DataTable
            {
                public void readResponseFile(string pathToFile)
                {
                    string[] lines = File.ReadAllLines(pathToFile);
                    for (int i = 1; i < lines.Length; i++)
                    {
                        string line = lines[i];
                        string[] words = line.Split('|');
                        DataRow r = this.NewRow();
                        this.Rows.Add(r);
                        for (int w = 0; w < words.Length; w++) r[w] = words[w];
                    }
                }
                public DataColumn dcId;
                public DataColumn dcRequestCulture;
                public DataColumn dcRequestQuery;
                public DataColumn dcRequestAddressLine;
                public DataColumn dcRequestAdminDistrict;
                public DataColumn dcRequestCountryRegion;
                public DataColumn dcRequestAdminDistrict2;
                public DataColumn dcRequestFormattedAddress;
                public DataColumn dcRequestLocality;
                public DataColumn dcRequestPostalCode;
                public DataColumn dcRequestPostalTown;
                public DataColumn dcRequestConfidenceFilterMinimumConfidence;
                public DataColumn dcReverseRequestIncludeEntityTypes;
                public DataColumn dcReverseRequestLocationLatitude;
                public DataColumn dcReverseRequestLocationLongitude;
                public DataColumn dcResponseAddressLine;
                public DataColumn dcResponseAdminDistrict;
                public DataColumn dcResponseCountryRegion;
                public DataColumn dcResponseAdminDistrict2;
                public DataColumn dcResponseFormattedAddress;
                public DataColumn dcResponseLocality;
                public DataColumn dcResponsePostalCode;
                public DataColumn dcResponsePostalTown;
                public DataColumn dcResponseNeighborhood;
                public DataColumn dcResponseLandmark;
                public DataColumn dcResponseConfidence;
                public DataColumn dcResponseName;
                public DataColumn dcResponseEntityType;
                public DataColumn dcResponseMatchCodes;
                public DataColumn dcResponsePointLatitude;
                public DataColumn dcResponsePointLongitude;
                public DataColumn dcResponseBoundingBoxEastLongitude;
                public DataColumn dcResponseBoundingBoxNorthLatitude;
                public DataColumn dcResponseBoundingBoxWestLongitude;
                public DataColumn dcResponseBoundingBoxSouthLatitude;
                public DataColumn dcResponseQueryParseValues;
                public DataColumn dcResponsePoints;
                public DataColumn dcStatusCode;
                public DataColumn dcFaultReason;
                public DataColumn dcTraceId;
                public objDataTableGecode()
                {
                    dcId = this.Columns.Add("Id", typeof(string));
                    dcRequestCulture = this.Columns.Add("GeocodeRequest/Culture", typeof(string));
                    dcRequestQuery = this.Columns.Add("GeocodeRequest/Query", typeof(string));
                    dcRequestAddressLine = this.Columns.Add("GeocodeRequest/Address/AddressLine", typeof(string));
                    dcRequestAdminDistrict = this.Columns.Add("GeocodeRequest/Address/AdminDistrict", typeof(string));
                    dcRequestCountryRegion = this.Columns.Add("GeocodeRequest/Address/CountryRegion", typeof(string));
                    dcRequestAdminDistrict2 = this.Columns.Add("GeocodeRequest/Address/AdminDistrict2", typeof(string));
                    dcRequestFormattedAddress = this.Columns.Add("GeocodeRequest/Address/FormattedAddress", typeof(string));
                    dcRequestLocality = this.Columns.Add("GeocodeRequest/Address/Locality", typeof(string));
                    dcRequestPostalCode = this.Columns.Add("GeocodeRequest/Address/PostalCode", typeof(string));
                    dcRequestPostalTown = this.Columns.Add("GeocodeRequest/Address/PostalTown", typeof(string));
                    dcRequestConfidenceFilterMinimumConfidence = this.Columns.Add("GeocodeRequest/ConfidenceFilter/MinimumConfidence", typeof(string));
                    dcReverseRequestIncludeEntityTypes = this.Columns.Add("ReverseGeocodeRequest/IncludeEntityTypes", typeof(string));
                    dcReverseRequestLocationLatitude = this.Columns.Add("ReverseGeocodeRequest/Location/Latitude", typeof(string));
                    dcReverseRequestLocationLongitude = this.Columns.Add("ReverseGeocodeRequest/Location/Longitude", typeof(string));
                    dcResponseAddressLine = this.Columns.Add("GeocodeResponse/Address/AddressLine", typeof(string));
                    dcResponseAdminDistrict = this.Columns.Add("GeocodeResponse/Address/AdminDistrict", typeof(string));
                    dcResponseCountryRegion = this.Columns.Add("GeocodeResponse/Address/CountryRegion", typeof(string));
                    dcResponseAdminDistrict2 = this.Columns.Add("GeocodeResponse/Address/AdminDistrict2", typeof(string));
                    dcResponseFormattedAddress = this.Columns.Add("GeocodeResponse/Address/FormattedAddress", typeof(string));
                    dcResponseLocality = this.Columns.Add("GeocodeResponse/Address/Locality", typeof(string));
                    dcResponsePostalCode = this.Columns.Add("GeocodeResponse/Address/PostalCode", typeof(string));
                    dcResponsePostalTown = this.Columns.Add("GeocodeResponse/Address/PostalTown", typeof(string));
                    dcResponseNeighborhood = this.Columns.Add("GeocodeResponse/Address/Neighborhood", typeof(string));
                    dcResponseLandmark = this.Columns.Add("GeocodeResponse/Address/Landmark", typeof(string));
                    dcResponseConfidence = this.Columns.Add("GeocodeResponse/Confidence", typeof(string));
                    dcResponseName = this.Columns.Add("GeocodeResponse/Name", typeof(string));
                    dcResponseEntityType = this.Columns.Add("GeocodeResponse/EntityType", typeof(string));
                    dcResponseMatchCodes = this.Columns.Add("GeocodeResponse/MatchCodes", typeof(string));
                    dcResponsePointLatitude = this.Columns.Add("GeocodeResponse/Point/Latitude", typeof(string));
                    dcResponsePointLongitude = this.Columns.Add("GeocodeResponse/Point/Longitude", typeof(string));
                    dcResponseBoundingBoxEastLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/EastLongitude", typeof(string));
                    dcResponseBoundingBoxNorthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/NorthLatitude", typeof(string));
                    dcResponseBoundingBoxWestLongitude = this.Columns.Add("GeocodeResponse/BoundingBox/WestLongitude", typeof(string));
                    dcResponseBoundingBoxSouthLatitude = this.Columns.Add("GeocodeResponse/BoundingBox/SouthLatitude", typeof(string));
                    dcResponseQueryParseValues = this.Columns.Add("GeocodeResponse/QueryParseValues", typeof(string));
                    dcResponsePoints = this.Columns.Add("GeocodeResponse/GeocodePoints", typeof(string));
                    dcStatusCode = this.Columns.Add("StatusCode", typeof(string));
                    dcFaultReason = this.Columns.Add("FaultReason", typeof(string));
                    dcTraceId = this.Columns.Add("TraceId", typeof(string));
                    foreach (DataColumn dc in this.Columns) dc.DefaultValue = string.Empty;
                }
    
            }
        }
        
    }
    

    • Edited by Joel Engineer Thursday, December 26, 2013 1:20 PM
    • Marked as answer by jal2 Friday, December 27, 2013 8:58 AM
    Thursday, December 26, 2013 1:16 PM
  • I originally tried this at home, now here at work it compiles fine - well here at work I don't have the complete code of the project, so I'll have to try it again when I get home.  Thanks.
    Thursday, December 26, 2013 5:11 PM
  • Ok I AM a dork. At home I didn't realize I had written the code like this:

    DataTable dt = new objDataTableGecode();

    Naturally the method was not found...

    Friday, December 27, 2013 8:58 AM