|
C++ programmers sometimes treat integers as Boolean values, where 0 is false and non-zero is true. This doesn't work in C#, which is more strongly typed.
If this is what you want to do, it can be written:
((x != 0) && (y != 0))
|
|
|
|
|
C# doesn't use (int)1 as true , so you will need to use (x==y && y==1)
see the link below, but to make a long story short, the C# compiler tends
to be more like a binary child, it likes things in strong typed format,
as such if there is any disention inside its ranks, it will just throw a compilation error.
just try something like
int a = Math.Round(Math.PI,0);
which throws Error:
Cannot implicitly convert type 'double' to 'int'.<br />
An explicit conversion exists (are you missing a cast?)
and can be resolved by
int a = (int)Math.Round(Math.PI,0);
but you cannot use:
int a = 2, b = 3;
if((bool)(a)&&(bool)(b)){}
alternativly you can restructure to just use bools
bool bx;
bx = false;
bx != bx;
or make an operator
BinaryAnd(int x,int y)
{
if(x==1&&y==1){return true;}
return false;
}
you should say more about how you intend to use it,
because there are lots of ways to get the same result.
clicky...hope it helps, my C is a bit rusty, it's been a couple of years.
|
|
|
|
|
Thank you all for your assistance!
Once you pointed me to the & operator I was on my way!
I think I should explain my use of the AND operator.
I have an enumerator of which each item/component has a binary value (1,2,4,8,16...etc)
I do this so that I can represent multiple of the enumerators values with a single integer.
E.g. the integer value 25 means that components 1, 8 & 16 are chosen.
When I want to add a enumerator value to the integer, I AND the int with the enumerators value, a result of 0 means that values hasn't been added yet and is safe to add.
//y is my enumerator
if ((TotalInt & (int)y) == 0) {
BinaryAddedValue = TotalInt + (int)y;
}
else {
BinaryAddedValue = TotalInt ;
}
So in my case, doing the AND between integers, I need to and the entire bytes and not just true or false for 1 and 0.
I actually havn't come around to testing it yet, hope it works...
Thanks again!
|
|
|
|
|
Hi,
I have a winforms application that I develop. The application is used for different projects and a variety of customers. Different projects require different features and I use the Settings of the application to control which features are available in each project. I am looking for a way to manage these features. Maybe have different settings files? I would like to be able to change these settings (as in user mode settings)
Any suggestions are welcome.
Thanks for your time
Natza Mitzi
|
|
|
|
|
I would create a build for each customer and use defined constants inside each build to customise the app as required.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am using msi installers. My thought was to add a custom action during the installation or on the first time the app is running and preset the variables.
Even so I am not happy with the solution since it seems too loose and not easy to maintain.
Thanks. If anyone has more ideas....
Natza Mitzi
|
|
|
|
|
I think your best bet may be to write a utility that allows you to create an appropriate app.config file (the basis for user mode settings), and use this utility to create custom versions of the app.config.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thata a general idea, I am looking for a nice solution "as typed as possible" and automated
Natza Mitzi
|
|
|
|
|
I think you're going to have to write it yourself because it is specific to your application. You can certainly make it generic, but that would be a LOT of work.
This is a pretty sticky problem, and I doubt you'll find many/any elegant solutions. Of course, you didn't provided enough info for a better answer.
How many different configurations are required?
Can the necessary settings be deduced from assemblies or files that accompany the application?
Why can't you re-factor the code to self-determine its available feature set? I think that would be the *best* thing to do.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The application I am developing is tough to develop as it moves from R&D to production very fast and many times. The application is installed to a variety of customers and different projects.
"How many different configurations are required?"
(-) Many and it is evolving.
Can the necessary settings be deduced from assemblies or files that accompany the application?
(-) Maybe but that is not the issue here. I do not want to deduct anything
Why can't you re-factor the code to self-determine its available feature set? I think that would be the *best* thing to do.
(-) This is not a matter of re factoring.
Thank you
Natza Mitzi
|
|
|
|
|
Are you trying to hide functionality purely for useabilty's sake or are you wanting to provide a cut-down version of your overall application?
If it's the latter you'll probably want to stay away from the idea of using the app.config file as anyone could edit it and get the extra functionality for free.
I'd probably recommend building some sort of licensing system into your application where a given key will unlock only certain features in the application though this will probably involve a fair amount of work on your end (depending on your application architecture).
It definitely isn't definatley
|
|
|
|
|
I am not too worried about someone enabling features and I think that the application settings are enough.
It seems like this is a good idea. Encode the features inside the application license key but I have to think about it more.
Any ideas about how to map the settings to an index that will not change during compilation? Maybe deterministic hashing? It will be awful,buggy and disgusting to maintain a map. I am also limited in the number of flags that I can have in such a key (even assuming that each one is a bit).
Thanks a lot
Another Idea is to create a post installer that will open the features in the application. That requires a wrap around the msi installer.
Natza Mitzi
modified on Wednesday, December 3, 2008 12:48 PM
|
|
|
|
|
Hi, I am using threading concept in my application to fetch the image form the video server and display.
the code is:
for (int i = 0; i < dataCount; i++)
{
doneEvents[i] = new ManualResetEvent(false);
ImageReader imgr = new ImageReader(doneEvents[i]);
objImageReader[i] = imgr;
WaitCallback callback = delegate(object state) { imgr.DownloadFile((structCameraServer)state); };
ThreadPool.QueueUserWorkItem(callback, objServer[i]);
}
WaitHandle.WaitAll(doneEvents);
but how to call the thread again after completion of the work (ie how to make the thread to start again).
Thanks in advance,
|
|
|
|
|
renuga5298 wrote: how to make the thread to start again
new Thread( ... )
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
assume like i have 10 threads intially, if i am restarting again with the new thread(...) wont the thread count be increased to 20 and when the number of the thread increases it may create probelm as i need to do this functionality for every 1 sec time interval.
|
|
|
|
|
renuga5298 wrote: but how to call the thread again after completion of the work (ie how to make the thread to start again).
Use Thread class other than ThreadPool . Don't end the thread when operation completes. Write your code in a loop and when each cycle completes, sleep for some time.
|
|
|
|
|
Can you please guide me in using the thread class for this scenario as i am new to threading
|
|
|
|
|
If your firing a thread off ever second, I would suggest the BackgroundWorker
its a lot easier to manage. You could check if its busy on each Tick and fire
it off again if not.
A craft is an enemy if not well learned.
|
|
|
|
|
i want to execute multiple dos commands on button click.
the commands are as follows:-
diskpart
select volume d:
assign letter=z
how can i perform it. and i want after execution it closes the command prompt.
thanks in advance
|
|
|
|
|
Write all commands to a bat file and start it using Process.Start . Write Exit command at the last line, so it will exit automatically after processing bat file.
|
|
|
|
|
I have tried this. this executes only "diskpart" command after that
select volume d:
assign letter=z
are not executed.
thanks 4 reply.
|
|
|
|
|
sumit7034 wrote: select volume d:
assign letter=z
are not executed.
You need to write that into the StandardInput of the process.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Can u please give a sample code to do this
thanks
|
|
|
|
|
sumit7034 wrote: Can u please give a sample code to do this
No, try figure it out first, then if you are still stuck on a specific issue tomorrow, come back, and we will try to help.
MSDN may have some sample code.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hello to all,
I am developing remote desktop capture application. I have done upto screen capture of remote shown to my pc. And i am transfer my mouse pressed coordinates to remote to open that dialog. But how can i open "start menu" with using mouse coordinates that already have?
Will you please help me out if anyone knows it?
Thank you.
|
|
|
|