Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:55:11+00:00 2026-06-12T16:55:11+00:00

private void updateButton_Click(object sender, EventArgs e) { //custID.Text = customers[id].ID.ToString(); customers[id].Name = custName.Text.ToString(); customers[id].Suburb

  • 0
    private void updateButton_Click(object sender, EventArgs e)
    {
        //custID.Text = customers[id].ID.ToString();
        customers[id].Name = custName.Text.ToString();
        customers[id].Suburb = custSuburb.Text.ToString();
        customers[id].Balance = custBal.Text;
        customers[id].Year_used = custYear.Text;
    }

}


public class Customer
{
    protected string id;
    protected string name;
    protected string suburb;
    protected double balance;
    protected double year_used;

    public string ID
    {
        get { return id; }
    }

    public string Name
    {
        get { return name; }
        set { value = name; }
    }

    public string Suburb
    {
        get { return suburb; }
        set { value = suburb; }
    }

    public double Balance
    {
        get { return balance; }
        set { value = balance; }
    }

    public double Year_used
    {
        get { return year_used; }
        set { value = year_used; }
    }


    public Customer(string id, string name, string suburb, double balance, double year_used)
    {
        this.id = id;
        this.name = name;
        this.suburb = suburb;
        this.balance = balance;
        this.year_used = year_used;
    }

}

Seems that i get this error when i try run the code?? what seems to be the issue i changed everything that had int to double.

As well as:

        customers[id].Balance = custBal.Text;
        customers[id].Year_used = custYear.Text;

What would be the proper code for the custBal. and custYear. to make it display on my form? any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:55:13+00:00Added an answer on June 12, 2026 at 4:55 pm

    Your user is entering a balance and is typing text, so how do you know the text can be represented by a number? C# will not let you convert a string to a double implicitely because there is no unique way to do that without make substantial assumptions about the string and implicit conversions should never throw an exception (Framework Design Guidelines), so it is best to not offer implicit conversion at all.

    For example, since it is a balance, what if the user types “(100.25)” or “-100.25” or “-$100.25” or “-€100,25” or “negative one hundred and twenty-five cents” All of those are valid strings, so how would you convert them to a double?

    The answer is that there is not one correct answer: you can map strings to double in any way that makes sense to you. You could, of course, write your own function of the form Func<String, double> but there are functions provided by the .Net framework that implement the most common and intuitive conversions.

    Others have posted double.Parse and double.TryParse so I want to add to make sure also to look into NumberStyles and IFormatProvider if necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void btnMiles_Click(object sender, EventArgs e) { try { int milesless200 = int.Parse(txtMiles.Text); int
private void btnBrowserGo_Click(object sender, EventArgs e) { browser.Navigate(txtBrowserURL.Text); } The code above directs the
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i <
private void button5_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(Data Source=MAZI-PC\\PROJECTACC;Initial Catalog=programDB;Integrated
private void button8_Click(object sender, EventArgs e) { List<long> averages; long res = 0; _fi
private void btnMail_Click(object sender, EventArgs e) { new formCustomerReportMailer().Show(); } Is it ill-advised to
private void NuestroButton1_Click(object sender, RoutedEventArgs e) { if //the sender's .Text/.Content is X {
private void Form1_Load(object sender, EventArgs e) { GetDataTable(@C:\Documents and Settings\agordon\Desktop\ACTIVITYEX.csv); } public System.Data.DataTable GetDataTable(string
private void button1_Click(object sender, EventArgs e) { using (SqlConnection sqlConn = new SqlConnection(Data Source=TANYA-PC;Initial
private void mnuCustomerAdd_Click(object sender, EventArgs e) { CustomerForm frmCust = new CustomerForm(Add A New

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.