|
|
In C/C++/Java/C# |= is to || or | what += is to + .
So it is a bit-wise or a logical assign-OR, depending on the operands' types.
|
|
|
|
|
Haha, sorry Luc, great answer, but I have to tell you how I read this:
Luc Pattyn wrote: |= is to || or | what += is to +
"or equals is to or or or what plus equals is to plus"
|
|
|
|
|
William Winner wrote: FontStyle style = someFont.Style;
style = FontStyle.Italic;
This is not equivalent to the first version, which effectively could be written as
FontStyle style = someFont.Style | FontStyle.Italic; This means that you are doing a logicalbitwise OR on the style, whereas your example here overwrites the style.
[Edit]Thanks for pointing out the error in this statement goes to Luc.
I'm not a stalker, I just know things. Oh by the way, you're out of milk. Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Monday, January 3, 2011 3:26 PM
|
|
|
|
|
as FontStyle is an enum, hence a numeric, it would be a bit-wise OR, not a logical one.
|
|
|
|
|
Doh. I completely forgot it was an enum. Slaps side of head.
|
|
|
|
|
Don't feel bad... Luc did too... He had fixed it by the time I clicked Reply on his post to point it out
|
|
|
|
|
With two small differences: I noticed the mistake and fixed it; and I didn't slap Pete's head.
|
|
|
|
|
|
Hi Guys, I'm facing a very weird problem, I'm referencing a third party dll in a windows service I'm developing.
When I add the reference, then include it in the using list and work with the dll everything is fine, intelesense picks up all the methods in the dll etc, but the moment that I build my project it gives exceptions on the dll, intelesense no longer recognizes it or the methods I used.
The excpetion I receive after the build is.. The type or namespace name 'XXX' could not be found (are you missing a using directive or an assembly reference?)
Any ideas or help would really be appreciated.
Thanks
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
I'm not sure if this will solve the problem, but one thing to check is that the dll gets copied to the output directory if it isn't in the GAC
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
It does not appear that the dll is being copied to the bin directory on the build. You can have a look at my message below for more detailed explanation of the setup.
Thanks for the reply.
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
In my experience the only way that can happen is if the dll is getting overwritten.
Since it is a 3rd party dll that would suggest that you are copying a new version in. Or even building to the wrong name perhaps (your library has the same name.)
|
|
|
|
|
Thanks for the reply.
I should clarify that by third party I mean that; the dll is a class library (developed by different team) residing under the same main solution as what the windows service (being developed by myself) is. So when I reference it I add the reference to the class library project under the solution and not the compiled dll as such, with the understanding that in doing so that when the solution builds that class library builds and the dll is supposed to be built to the bin directory of my service, which is currently not happening and I suspect that to be the problem.
But the strange thing is that if I just add the reference to the library, intelesense picks up the namespace of the library, I'm able to instantiate methods under the library etc, but as soon as I run that first build it no longer recognizes the namespace or any of the method instantiation.
I'll try changing the reference from the project to the compiled dll directly and hopefully that will help.
Thanks for the help.
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
JacquesDP wrote: I'll try changing the reference from the project to the compiled dll directly and hopefully that will help.
Scratch that one, tried it with the exact same result as referencing the project, works until the first build.
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
Think I might have found the problem, I never read the warnings on the build failure, and saw the following warning being displayed.
The referenced assembly "XXX.dll" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. CallCentreMgrNS
Thanks.
----MODIFIED-----
Changed the targeted framework of my service from .NET Framework 4.0 Client Profile to .NET Framework 4.0 and no the project builds successfully
No matter how long he who laughs last laughs, he who laughs first has a head start!
modified on Tuesday, January 4, 2011 2:38 AM
|
|
|
|
|
I am try to read serial of bytes and if I find the first byte is 55 and the second is 55 I will try till , I receive CC CC as a terminal.
but my problem is : when i reading I can find 55 55 and this is not start like this sample of bytes.
55 55 03 0A 0C 28
AA AA 00 00
99 08 F1 00 00 0B 09 0D
AA AA 5F 00
99 1E 3F 48 56 41 30 31 31 32 34 31 4E 4E 20 20 30 31 30 20 20 20 20 01 00 00 00 00 00 0D
AA AA 17 08
99 1E 3F 48 56 41 30 37 31 32 34 32 4E 4E 20 20 30 37 30 20 20 20 20 07 00 00 00 00 00 0D
55 55 03 0A 0C 2A [synch message every 3 minuits]
AA AA 04 09
99 08 F1 80 00 0B 09 0D
AA AA 0E 09
99 08 F1 80 00 0B 09 0D
AA AA 05 0A
CC CC [end of section]
What I want to ignore the message which start with 55 55 with length equal 6 because it's not the start of current block.
and here's My code :
1- I am Calculate Number of Blocks.
2- Then Store each block.
Current code neglect some bytes but I am not able to reach where's the logic error.
Note : All bytes are stored in VopMessageDetails ArrayList and I am converted from Hex to Decimal so 55 Hex Will equal = 85 and CC =204
int NblockCounter = 0;
int prevBlockLengths = 0;
#region To Get Numbers Of Blocks
for (int i = 0; i < VopMessageDetails.Count; i++)
{
if (VopMessageDetails[i].ToString() == "204")
{
i++;
NblockCounter++;
}
}
#endregion
List<String>[] catchBlockBytesArray = new List<String>[NblockCounter];
int blockCounter = 0;
catchBlockBytesArray[blockCounter] = new List<string>();
#region Catch blocks where each block stored as a item in catchBlockBytesArray.
for (int i = 0; i < VopMessageDetails.Count; i++)
{
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
{
if (VopMessageDetails[i].ToString() != "204")
{
if (VopMessageDetails[i].ToString() == "55" & VopMessageDetails[i + 1].ToString() == "55")
{
i += 6;
}
else
{
catchBlockBytesArray[blockCounter].Add(VopMessageDetails[i].ToString());
}
}
else
{
prevBlockLengths = i + 2;
i++;
blockCounter++;
if (i != VopMessageDetails.Count - 1)
{
if (blockCounter < NblockCounter)
{
catchBlockBytesArray[blockCounter] = new List<string>();
}
}
}
}
}
#endregion
}
}
}
|
|
|
|
|
Oh dear.
Firstly, stop using magic numbers. Define these as constant byte values with sensible names and use them instead. It makes your code more readable, and easier to maintain.
private constant byte SequenceInto = 0x55;
Secondly, stop converting to strings!
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
instead use:
if (VopMessageDetails[0 + prevBlockLengths] == SequenceIntro & VopMessageDetails[1 + prevBlockLengths] == SequenceIntro)
You may find this solves your problem:
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
{
if (VopMessageDetails[i].ToString() != "204")
{
if (VopMessageDetails[i].ToString() == "55" & VopMessageDetails[i + 1].ToString() == "55")
Did you forget to do the hex conversion here?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks for YOU , but you write the code as the same.
|
|
|
|
|
Yes. I did. It is a cut-and-paste section of your code with a likely error in in it.
When you rewrite your code to follow my two suggestions, you will get rid of the string comparisons in favour of constant based numeric comparisons. If you have only defined the values your are interested in, you can only use the correct values. That is one of the advantages of not using "magic numbers" in your code - it is harder to get it wrong.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi All
I am developing a website in C# using VS 2005, Is it possible to get
1) Visitor IP
2) Visitor Country
3) Visitor Browser Details
4) Visitor Logged Time
as email to my gmail account
Kind Regards
RK
|
|
|
|
|
You can store this data in a database and use an automated process, perhaps a SQL Job, to format and email it. There is nothing built-in that will do this if that's what you are asking.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Assumption: ASP.NET
You can get the first three from Request.Headers, but not the last.
The last is probably not possible, since everything is stateless and you can't tell when they leave unless there is a "log out" of some kind. If there is, then that's just a matter of doing a time difference between login and logout.
Emailing can be done with System.Net.Mail as long as you have an available SMTP server out there you can use.
|
|
|
|
|
E-mail seems like a terribly inefficient way to record that kind of data.
Try adding google analytics[^] to your site. It will give you way more than what you are looking for and probably take less time to add than some custom code for the short list you gave.
|
|
|
|
|
Hi,
I am using the open source provided at code project for SFTP. However it gives following error :
'Tamir.SharpSsh.jsch.Util' is inaccessible due to its protection level
Is Anyone aware of this error? How to resolve. Please help
|
|
|
|