|
Yes, val3 - val4 is greater than accuracy, but that leaves me with the problem that val3 == val1 is true, val1 == val4 is true, but val3 == val4 is false. A==B, B==C therefore A==C is a basic mathematical principal that this is breaking, and I'm afraid will cause problems, and I can't figure out a way around it.
Truncation isn't quite right either, that way 1.0000000001 and 1.00000000009 wouldn't match up.
I've since rewritten the equality method, to get much better results but no matter how I change it, I still can't get around that basic problem.
BTW, I've thought about using the Decimal structure for internal calculations, but I don't know how much it would gain me when most of the intermediate results will be stored outside of my class and will be in double.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
You will get better results if you round each value and then compare them, instead of checking the sum of the rounding errors.
Math.Round(this.Value, 10) == Math.Round(((SomeStruct)obj).Value, 10)
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have table with 2 columns
----------------------------------
DataSet dsABC = new DataSet();
dsABC.Tables.Add("ABC");
dsABC.Tables[0].Columns.Add("NAME",typeof(string));
dsABC.Tables[0].Columns.Add("AGE",typeof(int));
---------------------------------------------------
I am have a problem extracting the data from the columns ....
While I am doing
int Age = dsABC.Tables[0].Rows[0]["AGE"];
It says "Cannot implicitly convert type 'object' to 'int'".
Is there any way can we assign datacell to an int with out using Conver.Int32
Thanks And Regards,
Subbu
|
|
|
|
|
The only way I know of is to used typed datasets. They can be kind of a pain to setup (if you end up doing it manually, like I needed to for a recent project), but they are MUCH nicer to work with.
I don't have a link off hand, but I'm sure there's an article about them here on code project or MSDN.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
Hi,
Thanks for ur Information.
Can u give me any example which does manually.
I have gone through lots of sites ..I could not get a good example which creates Typed dataset manually
Thanks and Regards,
Subbu
|
|
|
|
|
int Age = (int)dsABC.Tables[0].Rows[0]["AGE"];
|
|
|
|
|
Thanks for ur information
But what is the point of declaring AGE column as of type "int" while defining the table.
|
|
|
|
|
Hi,
I like to wrap all controls before I use it in my own projects. It would be usefuel if the wrapped control is still accessible from the outside world. I can define a property on the wrapper and hand out the instance of the wrapped 3rd party control.
public class MyCustomButton
{
private 3rdParty.Controls.Button _button;
public 3rdParty.Controls.Button WrappedButton
{
get
{
return _button;
}
}
}
This way one is able to access programmatically. But if one changes something in the visual designer, the changes made on the wrapped control are lost, because they aren't written down by the designer into the IntitalizeComponents() method.
Is there any way to tell the designer to store the init settings for the wrapped control as well?
Thanks
myMsg.BehindDaKeys = "Jerry Maguire";
-- modified at 13:05 Thursday 19th January, 2006
|
|
|
|
|
I'm have to get (image)files at runtime in your slideshow viewer, so they can be displayed in the viewer.
The photos are first being displayed with a string that tells you were the file is located. When I push on the Add-button, the photo must be shown in the viewer.
Does anyone knows how to do that, it would be really helpfull...
thx
|
|
|
|
|
Hello guys,
I am having here some problems regarding pc's where the RPC server is not running or pc's where the windows firewall is causing my program to crash.
I am doing some inventories with WMI queries. Most of them it is not a problem, but there are PC's were the windows firewall is on and giving me the following error (from the log file):
DISCOVERY Error, sComputerType, System.Runtime.InteropServices.COMException: De RPC-server is niet beschikbaar. (Exception from HRESULT: 0x800706BA)
After 4 of this errors my program quits, altought that I am using Try Catch.
Is there a way to check if the 'RPC server is available' prior to the inventory process?
Thanks in advance.
The code for your info:
<br />
public static string GetInfoWithWMI(string _sComputerName, string _sParameter, string _sObjName, string _sObjQuery)<br />
{<br />
string sComputerName = _sComputerName;<br />
string sParameter = _sParameter;<br />
string sObjName = _sObjName;<br />
string sObjQuery = _sObjQuery;<br />
string sValue = "";<br />
<br />
try<br />
{<br />
ManagementScope scope = new ManagementScope("\\\\" + sComputerName + "\\root\\CIMV2");<br />
scope.Connect();<br />
ObjectQuery query = new ObjectQuery(sObjQuery);<br />
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);<br />
<br />
foreach (ManagementObject queryObj in searcher.Get())<br />
{<br />
if (queryObj[sObjName] != null)<br />
sValue = queryObj[sObjName].ToString();<br />
}<br />
if (Program._LoggingEnabled == "Y" && Program._LogDiscoveryProcess == "Y")<br />
Program.LogInfo("Discovery process: object=" + sComputerName + ", " + sParameter + "=" + sValue, 1);<br />
return sValue;<br />
}<br />
catch (System.Management.ManagementException mex)<br />
{<br />
<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Management.ManagementException: " + mex.Message, 3);<br />
}<br />
catch (System.Runtime.InteropServices.COMException comex)<br />
{<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Runtime.InteropServices.COMException: " + comex.Message, 3);<br />
}<br />
catch (System.Exception ex)<br />
{<br />
if (Program._LoggingEnabled == "Y" && (Program._LogDiscoveryProcess == "Y" || Program._LogProgramErrors == "Y"))<br />
Program.LogInfo("DISCOVERY Error, " + sParameter + ", System.Exception: " + ex.Message, 3);<br />
}<br />
<br />
return "";<br />
}<br />
|
|
|
|
|
Found a piece of code that should do the job.
<br />
System.ServiceProcess.ServiceController myController = new System.ServiceProcess.ServiceController("Remote Procedure Call (RPC)", sComputerName);<br />
if (myController.Status == ServiceControllerStatus.Running)<br />
sRPC = true;<br />
else<br />
sRPC = false;<br />
Feedback me if you think that is wrong.
|
|
|
|
|
Hello all!
I'm a rookie at C# and i'm wondering why the hell does a new class library project with one function added by me generates a DLL with no functions???
I'm I being very dumb here???
The project only have two classes: AssenblyInfo.cs and Class1.cs
Class1.cs defines a class with one function.
all compiles well but no functions on the DLL!!!!!!
Help!!!!
|
|
|
|
|
What does the Class1.cs look like and how do you know it has no functions?
If you have something like below, "Main" is to be called on Class1 .. eg, Class1.Main(...) .
public class Class1<br />
{<br />
public static void Main(string[] args)<br />
{<br />
}<br />
}
- Malhar
|
|
|
|
|
Hello!!! Thanks for answering.
When I create a new Class Library C# project it comes with 2 classes: AssemblyInfo.cs and Class1.cs
I have only added GetInt() to Class1.
I know that the DLL exports nothing by opening it and I can see that it has no exported functions.
This is what I have:
namespace MyProject
{
public class Class1
{
public Class1{}
public int GetInt(){return 100;}
}
}
|
|
|
|
|
uNsignedINT wrote: with 2 classes: AssemblyInfo.cs and Class1.cs
AssemblyInfo is not a class.
uNsignedINT wrote: DLL exports nothing by opening it and I can see that it has no exported functions
How do you open it?
In order for you to access GetInt() method, you must first create an object of type Class1.
E.g.
Class1 myObject = new Class1();<br />
myObject.GetInt();
|
|
|
|
|
Yes your right I meant 2 files
AssemblyInfo.cs and Class1.cs
I open the DLL with the Dependency Walker just by double cliking on the DLL.
It shows me all the dependant dll's and the the functions that exports.
How would you do a DLL in C# that is supposed to be used by another application?
Thanks!
|
|
|
|
|
Hello All!
Somenthing must have go wrong with my project.
I've created a new one with more functions and all was good.
I really can't tell what was the problem but now everything is ok.
thanks a lot for your help and patience!
Cumps!
|
|
|
|
|
uNsignedINT wrote: How would you do a DLL in C# that is supposed to be used by another application?
Expose the classes and methods to COM in your C# project. By default, this doesn't happen, and is why you can't see anything in Dependancy Walker.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how do i convert a string to a rich text format
thx
Nana
|
|
|
|
|
Easiest way of achieving this is:
Create an object of type RichTextBox
Set the Text to your non-RTF text to your RTFtextbox.
Get the RTF text by using the RTF property of the textbox.
- Malhar
|
|
|
|
|
This is a quick-and-dirty solution.
You should use some "manual" conversion.
___________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA]
|
|
|
|
|
Agree .. but it is guaranteed to work! Fast, simple, safe! Cant ask for anything more
To avoid performance issues, create and use a static object of type RichTextBox so you are not unncessearily create this object everytime.
- Malhar
|
|
|
|
|
You should use a manual approach if performance is important and the text is simple (limited formatting). If low maintenance or high reliability is important, use the RichTextBox. There is no point in writing code already provided by Windows - you will simply have more code to introduce bugs into.
|
|
|
|
|
Hi i have a Windows Application!!
In which i need to Display the Time of Two Countries,
For example:
When the application is Loaded, i want to Display the "Local Time/System Time" and "GMT time" and "Eastern Standard Time" on the window!!
In .NET there is option only for getting the current time zone!!("System.TimeZone.CurrentTimeZone");
!
Any helps or any sample codes or suggestion !! Please!
Thanks in advance!
One Shot dont miss you chance to go!!!!
|
|
|
|
|