473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Cannot implicitly convert type 'double' to 'double[]'

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Configuration;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Collections;
  6. using System .Collections.Generic ;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Xml.Linq;
  10. using System.IO;
  11. using System.Data.OleDb;
  12. using System.ComponentModel;
  13.  
  14. public partial class _Default : System.Web.UI.Page
  15. {
  16.     //class Point  { double X, Y; }
  17.     DataTable dt = new DataTable();
  18.     //int[][] polygon=new int[][];
  19.  
  20.  
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.  
  24.     }
  25.     protected void btnSubmit_Click(object sender, EventArgs e)
  26.     {
  27.         string connectionString = "";
  28.         if (FileUpload1.HasFile)
  29.         {
  30.             string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
  31.             string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName);
  32.             string fileLocation = Server.MapPath("~/App_Data/" + fileName);
  33.             FileUpload1.SaveAs(fileLocation);
  34.             if (fileExtension == ".xls")
  35.             {
  36.                 connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
  37.             }
  38.             else if (fileExtension == ".xlsx")
  39.             {
  40.                 connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
  41.             }
  42.             OleDbConnection con = new OleDbConnection(connectionString);
  43.             OleDbCommand cmd = new OleDbCommand();
  44.             ArrayList List = new ArrayList();
  45.             cmd.CommandType = System.Data.CommandType.Text;
  46.             cmd.Connection = con;
  47.             OleDbDataAdapter dAdapter = new OleDbDataAdapter(cmd);
  48.             DataTable dtExcelRecords = new DataTable();
  49.             con.Open();
  50.             DataTable dtExcelSheetName = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
  51.             string getExcelSheetName = dtExcelSheetName.Rows[0]["Table_Name"].ToString();
  52.             cmd.CommandText = "SELECT * FROM [" + getExcelSheetName + "]";
  53.             dAdapter.SelectCommand = cmd;
  54.             dAdapter.Fill(dtExcelRecords);
  55.             if (Session["dtInSession"] != null)
  56.             {
  57.                 dt = (DataTable)Session["dtInSession"];
  58.             }
  59.             for (int i = 0; i < dtExcelRecords.Rows.Count; i++)
  60.             {
  61.                int result;
  62.                 //if you want to get the string
  63.               DataRow thisRow = (DataRow)dtExcelRecords.Rows[i];
  64.               double[] X =Convert.ToDouble(thisRow["X"]);
  65.               double[] Y =Convert.ToDouble(thisRow["Y"]);
  66. //am getting above two line guy help me
  67.               polygonArea(X, Y);
  68.             }
  69.  
  70.         }
  71.     }
  72.     //calculation
  73.     private Double polygonArea(double[] X,double[] Y)
  74.     {
  75.  
  76.         Double area = 0.0;
  77.         int j = X.Length - 1;
  78.         for (int i = 0; i < X.Length; i++)
  79.         {
  80.             area = area + (X[j] + X[i] * (Y[j] - Y[i]));
  81.             j = i;
  82.         }
  83.         area = area / 2;
  84.         if (area < 0)
  85.             area = area * -1;
  86.         txtArea.Text=area.ToString() ;
  87.         return area;
  88.     }
  89.  
  90. }
Oct 5 '13 #1
1 6744
Rabbit
12,516 Expert Mod 8TB
A double and an array of doubles are not the same thing.
Oct 5 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Terminal882003 | last post by:
Hi, Here I have a question about MSCommLib. I need to dynamically add activeX controls that requires run-time license for MSCommLib. The following is the actual code: AxMSCommLib.AxMSComm...
3
by: Anita C | last post by:
I have the foll. code to update the value of an attribute: xmlDocument.Load("abc.xml"); XmlAttribute xmlAttrib = xmlDocument.SelectSingleNode(root/web/theme/@desc); xmlAttrib.Value =...
1
by: Svyatoslav | last post by:
Hi, I have a problem with XmlNodes and my stack. It looks something like this: //declarations XmlNode node, new_node; Stack MyStack = new Stack(); //code MyStack.Push(node);
22
by: Christoph Boget | last post by:
I am getting an error (a few among many) for the following lines of code: retval.BrokerName = (( curRow == System.DBNull.Value ) ? SqlString.Null : (string)curRow ); retval.BrokerGroupId = ((...
6
by: juli | last post by:
I declared: public delegate void PaintEventHandler(object objSender,PaintEventArgs pea); and this.Paint+=new PaintEventHandler(MyPaintHandler); and the: static void MyPaintHandler(object...
2
by: Patrick Olurotimi Ige | last post by:
When i convert:- this code from VB to C# Why do i get error "Cannot implicitly convert type 'object' to 'bool' VB --- If cmdcommand.Parameters("ReturnValue").Value = 1 Then lblStatus.Text =...
9
by: Andy Sutorius | last post by:
Hi, I am receiving the error when compiling the project, "cannot implicitly convert type object to string". The error points to this line of code and underlines the dtrRecipient:...
6
by: Doug | last post by:
Hi I have a short piece of trial code that compares some input and then produces a message based on the value. However I get a build error that i dont know how to resolve ' Cannot implicitly...
2
by: ransaj | last post by:
objCompanyRequirement.Salary = Convert.ToInt32 (txtCRF_Salary.Text); cannot implicitly convert type 'int' to 'string' objCompanyRequirement.InterviewDate = ...
3
by: sappyjosh | last post by:
public void Update_Stock(Inseed Is) { if (con.State == ConnectionState.Open) { con.Close(); } try { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.