|
How is that possible unless you have custom code. From msdn for 3.5:
ToolTip text is not displayed for controls that are disabled.
|
|
|
|
|
i am hoping this is an easy one. Is there an objective advantage to using a double of float, or vice versa?
I have a project that requires precision to 4 decimal places, so it seems like it is an either/or question, where neither would have a clear advantage over the other, but I was wondering if someone was familiar enough with the inner workings of the two types to say one is better than the other.
I am leaning toward double, since i have used it quite a bit in the past, but wanted a second opinion before going too far.
Looks liek i messed up, it should be decimal, not float. same question though.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
If you need a given precision, I would go with Decimal. Double are not precise numbers.
|
|
|
|
|
Vodstok wrote: requires precision to 4 decimal places
Four places total?
What's the range of values you need to cover?
I'm no expert on it, but the C# spec says:
"
The float type can represent values ranging from approximately 1.5 × 10^-45 to 3.4 × 10^38 with a precision of 7 digits.
The double type can represent values ranging from approximately 5.0 × 10^-324 to 1.7 × 10^308 with a precision of 15-16 digits.
The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 × 10^-28 to approximately 7.9 × 10^28 with 28-29 significant digits.
"
Unfortunately, when people tried to explain it to me in the past they simply said things like
"A float is precise to seven decimal places" which is not exactly correct and rather misleading.
|
|
|
|
|
Double is the floating point representation that is natively supported by tbe processor. It supports precision way beyond your requirement, but floating point numbers still have limited precision. Some numbers can't be represented exactly, so a number like 1.2345 might be stored as 1.234499999999999238. It's rounded off inside the precision when represented as text, so you normally never see the precision limitations.
Decimal is a fixed point number. It's twice the size of a double and not directly supported by the hardare, so calculations are a bit slower. As it's a fixed point number it supports exact precision, i.e. a number like 1.2345 is stored as the integer 12345 with a four digit decimal point shift.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If you need it to be precise use decimal. If you need it to be quick and are rounding later then use double. If it's for finance - definately use decimal!
Dave
|
|
|
|
|
Wow! thank you for all of the responses, it definately looks like decimal is the way i will be going.
Thank you for all of the responses
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
I am trying to allow one to three (3) files to be uploaded to a server, then send an email to the recipient for verification.
The files upload correctly and the email is sent, however it sends three emails for the one upload process.
What do I need to change in the code so that I only send one email for the complete process?
Any help would be appreciated.
Regards
Robert Caya
Here is the code for the process ...
default.aspx.cs
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
public partial class _mailUpload : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "d:\\Uploads";
HttpFileCollection uploadedFiles = Request.Files;
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
Label1.Text += "File #" + (i + 1) + " ";
Label1.Text += "File Name: " + userPostedFile.FileName + " ";
Label1.Text += "File Size: " + userPostedFile.ContentLength + "kb";
userPostedFile.SaveAs(filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName));
}
// Default is localhost or you can specify a host name or ipaddress of the email server
smtpClient.Host = "localhost";
//Default port is 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("rob@mydomain.com");
message.Subject = "Client File Upload System";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
//message.CC.Add("admin1@yoursite.com");
//message.CC.Add("admin2@yoursite.com");
// You can specify Address directly as string
//message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
//message.Bcc.Add(new MailAddress("admin4@yoursite.com"));
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = true;
// Message body content
message.Body = txtMessage.Text + "
The following files have been uploaded to the server.
" + Label1.Text;
// Send SMTP mail
smtpClient.Send(message);
lblStatus.Text = "Your email has been successfully sent.
The following files have been uploaded to the server.";
}
catch (Exception Ex)
{
Label1.Text += "There was an error sending your files ... " + Ex.Message;
lblStatus.Text += "Your email failed to send correctly ... " + Ex.Message;
}
}
}
#region "Reset"
protected void Button2_Click(object sender, EventArgs e)
{
txtName.Text = "";
txtEmail.Text = "";
txtMessage.Text = "";
Label1.Text = "";
}
#endregion
}
|
|
|
|
|
I guess the send method call is inside your for loop?
Dave
|
|
|
|
|
Dave
I am just learning some C# am not to good at it yet.
I understand what you are saying about the loop but I don't know how to make the change.
Could you help me out with the code?
Thanks
Robert
|
|
|
|
|
Robert
In the code below the send-mail is moved out of the loop.
now just create a try-catch for the moved part
Regards
Michael
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
public partial class _mailUpload : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "d:\\Uploads";
HttpFileCollection uploadedFiles = Request.Files;
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
Label1.Text += "File #" + (i + 1) + "";
Label1.Text += "File Name: " + userPostedFile.FileName + "";
Label1.Text += "File Size: " + userPostedFile.ContentLength + "kb";
userPostedFile.SaveAs(filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName));
}
//...send mail moved out of the loop...
}
catch (Exception Ex)
{
Label1.Text += "There was an error sending your files ... " + Ex.Message;
lblStatus.Text += "Your email failed to send correctly ..." + Ex.Message;
}
}
// Default is localhost or you can specify a host name or ipaddress of the email server
smtpClient.Host = "localhost";
//Default port is 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("rob@mydomain.com");
message.Subject = "Client File Upload System";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
//message.CC.Add("admin1@yoursite.com");
//message.CC.Add("admin2@yoursite.com");
// You can specify Address directly as string
//message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
//message.Bcc.Add(new MailAddress("admin4@yoursite.com"));
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = true;
// Message body content
message.Body = txtMessage.Text + "The following files have been uploaded to the server." + Label1.Text;
// Send SMTP mail
smtpClient.Send(message);
lblStatus.Text = "Your email has been successfully sent.The following files have been uploaded to the server.";
}
#region "Reset"
protected void Button2_Click(object sender, EventArgs e)
{
txtName.Text = "";
txtEmail.Text = "";
txtMessage.Text = "";
Label1.Text = "";
}
#endregion
}
|
|
|
|
|
Thanks for the help Michael and Dave.
I have it working now.
Cheers
Robert
|
|
|
|
|
I'm taking data from a database and feeding it into an application that takes an XML file as input. One of their fields is basically an enumerator value so I created a class that would attach the attribute to the field:
StaticType<int;> contractType;
...
[Serializable]
public class StaticType<T>
{
public StaticType( ) { }
public StaticType( T initialValue )
{
internalValue = initialValue;
initialValue = index;
}
private T initialValue;
private int initialIndex;
[XmlAttribute(AttributeName="staticValue")]
public T InternalValue
{
get { return initialValue; }
set { initialValue = value; }
}
}
The output works great and I get a field as such:
<someDataType staticValue="1" />
Here is the question:
Reading further into the documentation it looks like I might have to pass the value for some reason as well. So I'm puzzled as to how to construct the class so that my output gets created as:
<someDataType staticValue="1">some text value</someDataType>
Any ideas?
modified on Tuesday, February 19, 2008 1:17 PM
|
|
|
|
|
Using Xml serialization, you cannot have that construct. Instead, it would looks something like:
<someDataType staticValue="1"><Value>some text value </Value></someDataType>
You would require another property in your object, named Value (or whatever name you chose).
|
|
|
|
|
Yeh, that was the only solution I saw as well.
Thanks.
|
|
|
|
|
Hi. I have a project, which needs DirectX.AudioVideoPlayback to function and framework 2.0. How can i create an setup file, which would include everything thats need to run that application? The programe also needs some files in subdirectories.
Tnx. Bye
Força Barça!
|
|
|
|
|
|
I'm writing a GUI to run Powershell in C#. All is working and the test command "get-process" returns the output just fine.
There are a couple of peculiarities.
I tried adding a progress bar in the form, but I can't seem to trigger the progressChanged event. I put a breakpoint inside backgroundWorker1_ProgressChanged and the program never reached it while running the get-process command.
I also added an "Abort" button that executes this.backgroundworker1.CancelAsync(), but the output from "get-process" still displays after clicking that button.
Any help would be much appreciated.
-Jay
|
|
|
|
|
You'll need to call the ReportProgress method inside your DoWork (or from another function called by DoWork) method.
Dave
|
|
|
|
|
Thanks! That fixed the progress bar issue.
Any idea why the cancel button doesn't work?
-Jay
|
|
|
|
|
BackgroundWorker has a WorkerSupportsCancellation property that defaults to false - make sure it's set to true.
Dave
|
|
|
|
|
Yup I did set that property to "true".
I'm thinking that maybe a command like "get-process" actually finishes before I can even click the "Abort" button, and that the delay in execution time might be from generating the output. You think that's possible?
-Simon
|
|
|
|
|
Yes - very possibly. You could use break points and/or some Console.Write("xxx has completed") to figure out what's happening. Better still, once your get-process has completed set the Abort button to Enabled = false;
Dave
|
|
|
|
|
In your worker method you need to check the CancellationPending[^] property and abort the process if it's set to true.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Hi All,
I have a maskedtextbox with some values for the phone number: +49_________ .
when i come with the tabkey into the textbox, the cursor is located on the first character:
|+49_________ . Now how can i make it so that the cursor locates ofter the thirth char:
+49|_________ ????
|
|
|
|