Ошибка после выноса класса в отдельный файл - C#
Формулировка задачи:
Вынес данный класс в отдельный файл, не понимаю почему возникает ошибка: Error 1 The type or namespace name 'RailCrossings' could not be found (are you missing a using directive or an assembly reference?)
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data.OracleClient; using System.Data; namespace Service { public class RailCrossings { public int key; public string NAME; public int subdiv_gibdd; public int odh; public int category; public int USETYPE; public int OWNER; public int TRACK_DEPT; public int KM_POINT; public string STATION; public string PIQUET; public string PIQUET_PART; public int DUTY; public int NUM_SHIFTS; public int SHIFT_DURATION; public int NUM_DUTY; public string SERVICE; public int RAILCROSS_TYPE; public int BARRIER_STATE; public int SIGNAL_TYPE; public string PROTECT_FASC; public string CROSS_ROAD_NAME; public int HIGHWAY_CAT; public int VIEW_R_ODD; public int VIEW_R_EVEN; public int VIEW_L_ODD; public int VIEW_L_EVEN; public int VIEW_MID_TRAIN_ODD; public int VIEW_MID_TRAIN_EVEN; public int NUM_DAY_TRAINS; public int NUM_DAY_CARS; public int NUM_ROUTE_BUS; public int NUM_ROUTE_TRAM; public int NUM_ROUTE_TBUS; public int NUM_LINES_MAIN; public int NUM_LINES_STATION; public int NUM_LINES_OTHER; public int SPEEDMAX_FREIGHT_EVEN; public int SPEEDMAX_FREIGHT_ODD; public int SPEEDMAX_PASS_EVEN; public int SPEEDMAX_PASS_ODD; public int LOCATION; public string OPER_ORDER_NUM; public DateTime OPER_ORDER_DT; public DateTime DT_CARD_CREATE; public string POST_CARD_CREATE; public string NAME_CARD_CREATE; public int ADRESS; public int LATITUDE; public int LONGITUDE; } } основной файл где используется данный класс: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data.OracleClient; using System.Data; namespace Service { /// <summary> /// Summary description for test /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class ser : System.Web.Services.WebService { [WebMethod] public Point[] GetDictMapLayers(string KEY) { string sql = "select 'select s.' || POINT_TABLE_PK || ', to_char(s.' || POINT_TABLE_POINT || '.get_wkt()) from ' || POINT_TABLE || ' s' from MAP_LAYERS where key = " + KEY; sql = Convert.ToString(MB.GetSingleValue(sql)); DataTable Plaсe = MB.GetData(sql); Point[] elems = new Point[Plaсe.Rows.Count]; for (int i = 0; i < Plaсe.Rows.Count; i++) { Point three = new Point(); three.KEY = Convert.ToInt32(Plaсe.Rows[i][0]); three.points = Convert.ToString(Plaсe.Rows[i][1]); elems[i] = three; } return elems; } [WebMethod] public RailCrossings[] GetDictRailCrossings() { string SQL = "select KEY, NAME, SUBDIV_GIBDD, (select WM_CONCAT(vlu) from T2073A52 where RFR = r.key) as ODH, " + " OWNER, CATEGORY, USETYPE, TRACK_DEPT, KM_POINT, STATION, PIQUET, PIQUET_PART, DUTY, NUM_SHIFTS, SHIFT_DURATION, NUM_DUTY, SERVICE, RAILCROSS_TYPE, BARRIER_STATE, " + " SIGNAL_TYPE, PROTECT_FASC, CROSS_ROAD_NAME, HIGHWAY_CAT, VIEW_R_ODD, VIEW_R_EVEN, VIEW_L_ODD, VIEW_L_EVEN, VIEW_MID_TRAIN_ODD, VIEW_MID_TRAIN_EVEN, NUM_DAY_TRAINS, NUM_DAY_CARS, NUM_ROUTE_BUS, " + " NUM_ROUTE_TRAM, NUM_ROUTE_TBUS, NUM_LINES_MAIN, NUM_LINES_STATION, NUM_LINES_OTHER, SPEEDMAX_FREIGHT_EVEN, SPEEDMAX_FREIGHT_ODD, SPEEDMAX_PASS_EVEN, SPEEDMAX_PASS_ODD, LOCATION, OPER_ORDER_NUM, " + " OPER_ORDER_DT, DT_CARD_CREATE, POST_CARD_CREATE, NAME_CARD_CREATE, ADRESS, " + " (select d.FPOINT.SDO_POINT.x from MLR_T2073 d where item_key = key) as LATITUDE, " + " (select d.FPOINT.SDO_POINT.y from MLR_T2073 d where item_key = key) as LONGITUDE, " + " (select rtrim(DBMS_XMLGEN.CONVERT(to_char(sys_xmlagg(xmlelement(key, key || ',')).extract('/ROWSET/KEY/text()').getclobval()), 1),',') from t2690 where railcross = r.key) as KEY_OVERHAUL " + " from t2073 r "; DataTable d = MB.GetData(SQL); if (d.Rows.Count > 0) { //OracleParameter qryParam = new OracleParameter("T1554", 12); //OracleParameter[] qryParams = new OracleParameter[1]; //qryParams[] = qryParam; d = MB.GetData(SQL); RailCrossings[] information = new RailCrossings[d.Rows.Count]; for (int i = 0; i < d.Rows.Count; i++) { RailCrossings gibdd = new RailCrossings(); gibdd.key = d.Rows[i]["key"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["key"]); gibdd.NAME = d.Rows[i]["name"] is DBNull ? "" : Convert.ToString(d.Rows[i]["name"]); gibdd.subdiv_gibdd = d.Rows[i]["subdiv_gibdd"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["subdiv_gibdd"]); gibdd.odh = d.Rows[i]["odh"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["odh"]); gibdd.OWNER = d.Rows[i]["owner"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["owner"]); gibdd.category = d.Rows[i]["category"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["category"]); gibdd.USETYPE = d.Rows[i]["usetype"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["usetype"]); gibdd.TRACK_DEPT = d.Rows[i]["track_dept"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["track_dept"]); gibdd.KM_POINT = d.Rows[i]["KM_POINT"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["KM_POINT"]); gibdd.STATION = Convert.ToString(d.Rows[i]["STATION"]); gibdd.PIQUET = d.Rows[i]["PIQUET"] is DBNull ? "" : Convert.ToString(d.Rows[i]["PIQUET"]); gibdd.PIQUET_PART = d.Rows[i]["PIQUET_PART"] is DBNull ? "" : Convert.ToString(d.Rows[i]["PIQUET_PART"]); gibdd.DUTY = d.Rows[i]["DUTY"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["DUTY"]); gibdd.NUM_SHIFTS = d.Rows[i]["NUM_SHIFTS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_SHIFTS"]); gibdd.SHIFT_DURATION = d.Rows[i]["SHIFT_DURATION"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SHIFT_DURATION"]); gibdd.NUM_DUTY = d.Rows[i]["NUM_DUTY"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_DUTY"]); gibdd.SERVICE = d.Rows[i]["SERVICE"] is DBNull ? "" : Convert.ToString(d.Rows[i]["SERVICE"]); gibdd.RAILCROSS_TYPE = d.Rows[i]["RAILCROSS_TYPE"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["RAILCROSS_TYPE"]); gibdd.BARRIER_STATE = d.Rows[i]["BARRIER_STATE"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["BARRIER_STATE"]); gibdd.SIGNAL_TYPE = d.Rows[i]["SIGNAL_TYPE"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SIGNAL_TYPE"]); gibdd.PROTECT_FASC = d.Rows[i]["PROTECT_FASC"] is DBNull ? "" : Convert.ToString(d.Rows[i]["PROTECT_FASC"]); gibdd.CROSS_ROAD_NAME = d.Rows[i]["CROSS_ROAD_NAME"] is DBNull ? "" : Convert.ToString(d.Rows[i]["CROSS_ROAD_NAME"]); gibdd.HIGHWAY_CAT = d.Rows[i]["HIGHWAY_CAT"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["HIGHWAY_CAT"]); gibdd.VIEW_R_ODD = d.Rows[i]["VIEW_R_ODD"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_R_ODD"]); gibdd.VIEW_R_EVEN = d.Rows[i]["VIEW_R_EVEN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_R_EVEN"]); gibdd.VIEW_L_ODD = d.Rows[i]["VIEW_L_ODD"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_L_ODD"]); gibdd.VIEW_L_EVEN = d.Rows[i]["VIEW_L_EVEN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_L_EVEN"]); gibdd.VIEW_MID_TRAIN_ODD = d.Rows[i]["VIEW_MID_TRAIN_ODD"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_MID_TRAIN_ODD"]); gibdd.VIEW_MID_TRAIN_EVEN = d.Rows[i]["VIEW_MID_TRAIN_EVEN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["VIEW_MID_TRAIN_EVEN"]); gibdd.NUM_DAY_TRAINS = d.Rows[i]["NUM_DAY_TRAINS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_DAY_TRAINS"]); gibdd.NUM_DAY_CARS = d.Rows[i]["NUM_DAY_CARS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_DAY_CARS"]); gibdd.NUM_ROUTE_BUS = d.Rows[i]["NUM_ROUTE_BUS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_ROUTE_BUS"]); gibdd.NUM_ROUTE_TRAM = d.Rows[i]["NUM_ROUTE_TRAM"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_ROUTE_TRAM"]); gibdd.NUM_ROUTE_TBUS = d.Rows[i]["NUM_ROUTE_TBUS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_ROUTE_TBUS"]); gibdd.NUM_LINES_MAIN = d.Rows[i]["NUM_LINES_MAIN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_LINES_MAIN"]); gibdd.NUM_LINES_STATION = d.Rows[i]["NUM_LINES_STATION"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_LINES_STATION"]); gibdd.NUM_LINES_OTHER = d.Rows[i]["NUM_LINES_OTHER"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["NUM_LINES_OTHER"]); gibdd.SPEEDMAX_FREIGHT_EVEN = d.Rows[i]["SPEEDMAX_FREIGHT_EVEN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SPEEDMAX_FREIGHT_EVEN"]); gibdd.SPEEDMAX_FREIGHT_ODD = d.Rows[i]["SPEEDMAX_FREIGHT_ODD"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SPEEDMAX_FREIGHT_ODD"]); gibdd.SPEEDMAX_PASS_EVEN = d.Rows[i]["SPEEDMAX_PASS_EVEN"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SPEEDMAX_PASS_EVEN"]); gibdd.SPEEDMAX_PASS_ODD = d.Rows[i]["SPEEDMAX_PASS_ODD"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["SPEEDMAX_PASS_ODD"]); gibdd.LOCATION = d.Rows[i]["LOCATION"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["LOCATION"]); gibdd.OPER_ORDER_NUM = d.Rows[i]["OPER_ORDER_NUM"] is DBNull ? "" : Convert.ToString(d.Rows[i]["OPER_ORDER_NUM"]); gibdd.OPER_ORDER_DT = d.Rows[i]["OPER_ORDER_DT"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(d.Rows[i]["OPER_ORDER_DT"]); gibdd.DT_CARD_CREATE = d.Rows[i]["DT_CARD_CREATE"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(d.Rows[i]["DT_CARD_CREATE"]); gibdd.POST_CARD_CREATE = d.Rows[i]["POST_CARD_CREATE"] is DBNull ? "" : Convert.ToString(d.Rows[i]["POST_CARD_CREATE"]); gibdd.NAME_CARD_CREATE = d.Rows[i]["NAME_CARD_CREATE"] is DBNull ? "" : Convert.ToString(d.Rows[i]["NAME_CARD_CREATE"]); gibdd.ADRESS = d.Rows[i]["ADRESS"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["ADRESS"]); gibdd.LATITUDE = d.Rows[i]["LATITUDE"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["LATITUDE"]); gibdd.LONGITUDE = d.Rows[i]["LONGITUDE"] is DBNull ? 0 : Convert.ToInt32(d.Rows[i]["LONGITUDE"]); information[i] = gibdd; } return information; } else { RailCrossings[] ver = new RailCrossings[0]; return ver; } } } public class Point { public int KEY; public string points; } }
Решение задачи: «Ошибка после выноса класса в отдельный файл»
textual
Листинг программы
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data.OracleClient; using System.Data; namespace Service { public class RailCrossings { public int key; public string NAME; } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д