|
firstly I think youve made a typo (either in your code or in transposing it to a post)
fmardani wrote: if (!(intPosHomeUS > 0 && intPosHomeUK > 0) || (intPosHomeUK > 0 && intPosHostUS > 0))
should that be
if (!(intPosHomeUS > 0 && intPosHomeUK > 0) || (intPosHostUK > 0 && intPosHostUS > 0))
if not, and its correct, I could break down the code as
if(! (false && true) || (true && true))
breaks down further as
if( ! (false || true) )
and once more as
if(!true)
so
!true == false
so your message box will not show.
|
|
|
|
|
Doesn't it evaluate to:
(!false || true)
rather than
!(false || true)
Which would of course trigger the message box? I tend to go overboard with the parens just to make sure I'm negating the right thing because of stuff like this.
|
|
|
|
|
eggsovereasy wrote: I tend to go overboard with the parens just to make sure I'm negating the right thing because of stuff like this.
me too!
In my post I am assuming (rather than have tested) that it is evaluated as
!(false || true)
rather than
(!false || true)
|
|
|
|
|
The negation operator (!) has a higher precedence than the logical or operator. I think you made a typo yourself when you went from steps:
if(! (false && true) || (true && true))
To:
if( ! (false || true) )
Personally, I would suggest just using the debugger and putting a watch in to see what exactly is going in. Put the full statement "(!(intPosHomeUS > 0 && intPosHomeUK > 0) || (intPosHostUK > 0 && intPosHostUS > 0))" and then break it down into pieces to find the error.
As a side note, I'm not a big fan of putting a negation like that because it always seems to trip me up (may just be me). So, I typically pass the negation through the set...so you'd have something like this instead:
if (intPosHomeUS <= 0 || intPosHomeUK <= 0 || (intPosHostUK > 0 && intPosHostUS > 0))
It's just DeMorgan's Law...you can find more about it here[^].
|
|
|
|
|
Andrew Rissing wrote:
As a side note, I'm not a big fan of putting a negation like that because it always seems to trip me up (may just be me). So, I typically pass the negation through the set...so you'd have something like this instead:
It tends to trip me up as well, but I prefer writing the exression in the intuitive 'as english' format and either using a temp var for the base expression and then notting the temp in the expression or switching the then and else clauses around to avoid the negation all together.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
fmardani wrote: I believe the following values should make the statement to show the messagebox.
Yes, it should, and it does.
---
b { font-weight: normal; }
|
|
|
|
|
Is this a logic issue? I noticed that you're not checking for a value from intPosHostUK
|
|
|
|
|
Hi,
I need to know how can I create shotcut to myButton on form when I press key F10 independent of current active control on form, without using "ShortcutKey" in "ToolStipMenuItem".
I can do this if myButton is active control on form. I explicitly need to use key F10, so I can't use an & (ampersand) in a button text.
Thanks for help
|
|
|
|
|
handle key down or key up event of the form and then trigger click event by;
if(e.KeyCode == Keys.F10)
button1.PerformClick();
hope it helps.
Regards
Khalid
|
|
|
|
|
Hello,
And dont't forget to set:
this.KeyPreview = true;
All the best,
Martin
|
|
|
|
|
Thanks both, it really works.
|
|
|
|
|
Hi,
I have just one more question. Can I check if ALT+F1 pressed?
Thanks,
Jure
|
|
|
|
|
Hello,
Yes you can!
if (e.Alt && e.KeyCode == Keys.F1)
Hope it's not too late, but I didn't got your post.
All the best,
Martin
|
|
|
|
|
Thanks, it's not too late.
Thanks again,
Jure
|
|
|
|
|
Excuse me for being brief, but it is self explanatory.
So I make a query with linQ, and then try to make a 2nd query on the previous results, but there i get an error.
List<clsHotel> q = from d in dbGet.Hotels()
select d;<br />
<br />
if (chkHalfpension.Checked) {<br />
List<clsHotel> z = from x in q
where x.Naam == "Bon jour" <br />
select x;<br />
}
It returns the following error on that line:
Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<hotelmanager.data.clshotel>' to 'System.Collections.Generic.List<hotelmanager.data.clshotel>'. An explicit conversion exists (are you missing a cast?)
If anyone could please help.
Thanks in advance !
-- Edit --
The weird thing is:
This code also doesnt works:
List<clsHotel> q = from d in dbGet.Hotels()
select d;<br />
<br />
List<clsHotel> z = from vx in dbGet.Hotels()
select vx;
It throws the same error, but the code is the same :s
Guess it's an bug in c#3.0 ?
-- modified at 8:18 Thursday 2nd November, 2006
|
|
|
|
|
instead of list, have you tried var?
|
|
|
|
|
Yes, keeps saying the same error.
I guess you can't do 2 of that select things in the same function, wich is to bad
|
|
|
|
|
Have you tried IEnumerable < string > < == remove spaces
|
|
|
|
|
This works ! (except i used clsHotel class, not string)
Thanks alot edboe !
|
|
|
|
|
Another option would be to create each search in a separate function/method.
|
|
|
|
|
What i want to be able to do is change a Color that i get from a method to a lighter version. E.g: If its red, make it a lighter shade of red.
Any ideas how i'd do this?
Regards,
Gareth.
|
|
|
|
|
Hello,
I think this should do it.
Color _lightcolor = ControlPaint.Light(Color.Red);
Hope that helped you.
All the best,
Martin
|
|
|
|
|
Hi
If I output the result of a web-method as a struct defined in my web-service, how do I then use that outputted result (i.e. the struct and its properties, methods, etc.) in the calling client application?
Here is the struct:
public struct DataType_Shop_SKU
{
public Int32 SKUID;
public String Name;
public String WebDescription;
}
Here's the web-method:
public DataType_Shop_SKU GetSKU(int SKUID)
{
clsShop Shop = new clsShop();
try
{
MyDataTypeSKU = Shop.GetSKUBySKUID(SKUID); // populates the struct
}
Thank you for your help.
|
|
|
|
|
Make a dll of the struct and refer it to both client and the server.
Regards
Khalid
|
|
|
|
|
Hi All,
Given a string filename, eg:
string filename = @"c:\my folder\my second folder\myfile.txt";
Is there a neat-o way of getting the directory that the file is in, other than using string manipulation or regular expressions?
I'd expected that there would be a File class with a (read-only) property of Directory, such that one could get the directory a bit like this:-
string directory = new File(@"c:\my folder\my second folder\myfile.txt").Directory;
but I cannot find anything like that.
Thanks
Jon
|
|
|
|