|
I have been searching around for about 2 hours and decided to resort to posting a question. Sorry because I know this question has to of been answered before.
Ok....so my question is how do i manipulate a number so that it is a multiple of 10....
such as .... 57 = 60
The number 57 would go to the number 60.
To my knowledge I would use the Math.Something, but I searched through the C# variables and did not find anything that would work.
Anyhelp would be greatly appreciated.
|
|
|
|
|
Well, there's Math.Round, but you may have to do a little work to get what you want:
double multiple = 10;
double value = 57;
double result = Math.Round(value / multiple) * multiple;
Console.WriteLine(result);
|
|
|
|
|
Ok, thank you for your response.
I knew there had to be a way to use Math.Round and get the answer, but i wasn't clever enough to think of your equation. Thanks for the response maybe now I'll be able to finish my homework.
|
|
|
|
|
Well....I would suppose you do something like this
int number = 57;
int remainder= number%10;
if(remainder< 5)
{
number += remainder;
}
else
{
number -= remainder;
}
That will probably give you the best results...and if you're doing this for homework, that's probably the way they wanted you to do it in the first place
-- modified at 15:17 Tuesday 3rd October, 2006
|
|
|
|
|
This is my take, it's easier than the other ones:
int bla = 57;
int rem = (bla % 10);
bla += (rem == 0) ? 0 : 10 - rem;
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have created a windows service that looks for the existence of a running process and if the process does not exist it will start it. So far this works great, however I have a scenario where sometimes this process will be running multiple times for different customers. When it is kicked off for a customer, their ID is passed as an argument when the process starts up. Is there any way to see what arguments are being used in a running process? I have looked at using remoting, but it seems like overkill to get the info that I need. I also looked at setting the MainWindowTitle so I can look at that, but that doesn't seem to work either. In a nutshell, I want to say is process A running, Yes then for who?
Any help would be appreciated.
Thanks
Sean
|
|
|
|
|
Couldn't you just use a Mutex. Have the process create a Mutex with a name that includes its customer Id. If the expected mutex exists, the customers process is running.
This may be simpler than running through all the processes and has the added benefit of preventing duplicate executions of an individual customers application.
|
|
|
|
|
The mutex looks like it will work great. Thanks
Sean
|
|
|
|
|
UTRocketFan wrote: In a nutshell, I want to say is process A running, Yes then for who?
Maybe you mean Process.Username property? It's available only in .Net 2.0 though.
Regards
|
|
|
|
|
The project I'm currently working on high level has 3 primary projects:
<solution>
|-> Definitions [dll]
|-> ClientConsole [exe]
|-> ServerConsole [exe]
Definitions project has no references. ClientConsole is an exe that will be distributed on clients and references "Definitions" project.
ServerConsole is an exe that will be distributed on server(s). But the requirements allow, server to present itself as a client and thus be an acting "client".
My question:
How do I add "ClientConsole" as a reference to the "ServerConsole" project as the server needs to be able to instantiate the client related objects (UI, other classes). The "Add Reference" fails since "ClientConsole" is of type exe.
I can NOT make "ClientConsole" a class-library and add a new additional EXE project just for launching the ClientConsole.
I have tried all of the following:
1. Keep ClientConsole an exe, and as a "Post build event" on "ClientConsole" project to copy and rename itself as a DLL to the references folder of "ServerConsole" project. This does not work because ...
a) Visual Studio locks the DLLs and thus the new DLL cannot be copied to the destiation folder
b) Even if VS does not lock the file, the intellisense will not reflect the changes in ClientConsole when editing code for ServerConsole when "ClientConsole" is updated
2. Change ClientConsole to a DLL project, and add it as a project reference to ServerConsole. I'll have solved my issue with intellisense and VS picking up the correct DLLs. And as an icing on the cake, set the "post build event" on "ServerConsole" project to rename the "ClientConsole.dll" file to "ClientConsole.exe". This is an ideal solution for me, but this also bomb because ...
a) when the client is compiled as a DLL, the entry poing info "Main()" is not defined so renaming the DLL to an EXE throws error that it's an invalid Win32 app.
I'm sure I'm not the first one to encounter this error. What do you suggest?
Thanks,
- Malhar
|
|
|
|
|
malharone wrote: I can NOT make "ClientConsole" a class-library and add a new additional EXE project just for launching the ClientConsole.
Why not?
malharone wrote: I'm sure I'm not the first one to encounter this error. What do you suggest?
State the obvious and suggest you move the relevant parts to a new Class Library and have ClientConsole become a bootstrap to the controls and forms in the new class library.
|
|
|
|
|
Colin Angus Mackay wrote: Why not?
Unfortunately, where I work, it is the "Business" that makes tbe technical decision. They want to have a simplified client-side deployment process. One additional DLL and the hell breaks loose!
They've dictated that clients should have "Definitions.dll" and the "ClientConsole.exe" only. Rest of the 3rd party dependent references are already installed, so the installer only copies 2 files on the client machine.
Colin Angus Mackay wrote: State the obvious
I was hoping that from the post build event of "ServerConsole", somehow I could recompile the ClientConsole as a WinExe application.
|
|
|
|
|
malharone wrote: the ClientConsole as a WinExe application
hmm.. I could do that.. I should do that given the constraints
|
|
|
|
|
Hi,
We are using data-binding & typed datasets in our C# .NET 2.0 application (VS2005). We have a bindingsource which has as datasource a dataset and as datamember a datatable.
In the form we have a grid which is binded to that bindingsource. We allow new records to be created on the grid.
When the users navigates to a new row, the "Adding New" event is raised. We would like to handle this event because we need to set the key of the record to a new Guid.
We get as parameter of the "Adding New" function "AddingNewEventArgs e".
Then e.NewObject should be set. Well, this doesn't work. After setting the e.NewObject the program crashes.
It's like it does not accept my Typed DataRow. Maybe the collection underneath in the Bindingsource accepts another type?
Any ideas?
Best regards,
Jens
|
|
|
|
|
JensB wrote: we need to set the key of the record to a new Guid.
I did that in several data-bound DataGridViews with no problems. You don't set the e.NewObject to something. Here is how I did it.
private void MyDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
MyDataGridView.Rows[e.RowIndex].Cells[0].Value = Guid.NewGuid().ToString();
}
Regards
|
|
|
|
|
Hello
How can i increase level of run my program in the Win XP
Thanks
|
|
|
|
|
Umm... What is "level of run"?
Regards
|
|
|
|
|
in the work with hardware which interrupt in the XP responced!
Thanks
|
|
|
|
|
That didn't clear things up at all.
Are you asking how to write a driver for a hardware device? Or how your application can communicate with a device? What kind of device?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If you read that in an article or got some link that would explain what you mean, I'd greatly appreciate it.
Regards
|
|
|
|
|
Do you mean the priority of the application? Where increasing the priority of the application will increase the speed of the application but if set to high it will degrade the performance of the rest of the system?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
|
|
|
|
|
Hi all,
I've been playing with excell for a bit and i saw that i can import data from a xml file...
Is is possible to do so through c#? 2 export data from xml to excell?
-- modified at 9:55 Tuesday 3rd October, 2006
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hello
You can write your DataSet to Xml text using DataSet.WriteXml() ,ethod. Then you can write it to an Xml file using XmlDocument class.
Regards
|
|
|
|
|
mejojo-
Thank you for your response. I forgot to specify we have not upgraded to the 2.0 framework. We are on 1.1 System.IO.SearchOption opt = System.IO.SearchOption.AllDirectories; does not seem to work.
My first attempt(b4 the post) was
DirectoryInfo di = new DirectoryInfo(@"C:\Temp");
foreach(DirectoryInfo file in di.GetDirectories())
{
Response.Write("File Info \""+file.FullName+"\""+"
");
}
But this does not go into subdirectiories. Can some one help?
What is the best option for displaying the result set to the web, DataGrid? Instead of Console.WriteLine what would I use for the web? From what I was told I a console app is done the same way from a Web App (ASP.NET) but Console.WriteLine does not display my result set.
Thanks in advance.
|
|
|
|
|
Hello
iamnew2C# wrote: I forgot to specify we have not upgraded to the 2.0 framework
I was postulating here in the forum for sometimes that if you want some functionality of a certain library of .Net framework, you can install it on your machine and explicitly reference to that library. So you'd be using .Net 1.1 for everything else, yet enjoy this new feature of .Net 2.0 or even 3.0.
iamnew2C# wrote: But this does not go into subdirectiories
Sure it won't. You have to put this code in a recursive function and recall it each time.
iamnew2C# wrote: What is the best option for displaying the result set to the web
You are enumerating Directories. I guess a TreeView would do the job.
Regards
|
|
|
|