|
It may work most of the time, but | is not same as ||. The compiler doesn't short-circuit the evaluation.
Please use the proper operator, for your successor's sake.
BTW I am not sure if you do the same for & vs &&
if(a != null & a.Name != "abc") will throw you an "object reference....." exception.
|
|
|
|
|
darkelv wrote: BTW I am not sure if you do the same for & vs &&
yeah, i do but i never have any problem in using single (| and &)
Becoming Programmer...
|
|
|
|
|
Well then, I hope you will use the correct operator, else, you will have people in the future in your work asking (demanding) you to do so.
Also, it's is related to your original question. If you use bit wise OR or AND, each of them will be evaluated regardless (no short-circuiting). Beside, you will be doing AND or OR operations instead of CMP operation all the time.
|
|
|
|
|
|| is a logical or, the | a bitwise or (if I'm not mistaken)
|
|
|
|
|
thanks for your all, now its time to go
Becoming Programmer...
|
|
|
|
|
xmen_xwk wrote: so buddies please reply ASAP.
Why should we help you CHEAT on a test?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
CHEAT!!! what are you talking about, i wasnt in examination room, i asked before the starting exam
Becoming Programmer...
|
|
|
|
|
xmen_xwk wrote: i wasnt in examination room
Whew, okay How did it go, by the way?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
yep good, i got 94 %
Becoming Programmer...
|
|
|
|
|
Very good for you
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: for you
what do you want to say
Becoming Programmer...
|
|
|
|
|
it is bit datatype in sql server 2000.What should be it 's equivalant in c#
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Since a bit is truly a binary value (on/off, yes/no, true/false) the closest representation in C# is a bool .
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]<</div>
|
|
|
|
|
bool represents true and false
but bit represents 1 0
don't u think it is a mismatch?
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
No, there really isn't a mismatch. In both cases they represent a binary state (on/off, true/false, yes/no, 0/1, etc.). The "bool" data type is a relatively new data type and wasn't present in the original C family of languages. It was usually defined as TRUE = 1 or TRUE = 0, depending on the developer. That was one of the reasons for the creation of an actual data type, to create a standard reprentation so TRUE always meant the same value in all cases.
A lot of databases still use a bit data type to represent a boolean value so the binary state of the data type is still true. If you're using any of the ADO.NET classes, the data type mapping between bit and bool is handled automatically for you.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]<</div>
|
|
|
|
|
ok Thanks .
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Hi,
We are working on a project where we need to identify the number of pages in a tif/pdf file from our .net application.
Please let me know how to proceed in this regard. One way to proceed is to use some third party tools for this purpose for for this project, we will not be able to use any external tools.
Thanks in advance
RS
|
|
|
|
|
How can I disable or enable the TCP/IP port using C#?
Thank you!
|
|
|
|
|
use the blocksocket function
|
|
|
|
|
Hey ya'll,
I'm trying to find if a file is a valid image file by;
try
{
Image img = Image.FromFile(str);
}
catch
{
Continue on with biz
}
And when it encounters a non-image file it throws and OutOfMemory exception as described in docs.
My question;
Is there another way to check if valid image file besides;
if (gif or png or jgp or......)
img = ......
After I make this call the app crashes at some point telling me theres memory corruption somewhere. I've narrowed it down to this try/catch block.
Thanks,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
Hi,
you can check the file extension; or you can read the first 1024 bytes and look for
specific values (eye catchers) that exist in most of the image formats. These checks,
although a bit ugly and different for each format, will help you in rejecting files
that do not contain image information at all, leaving only image candidates.
But then there could be bad image files, damaged JPEGs and the like. I know of no
general way to detect these, other than trying to load them.
So I would combine all the above, so the try-catch only serves to deal with bad
image files.
|
|
|
|
|
Hey Luc,
Thanks for the quick response, much ablidged!
I was afraid that would be the answer but inquiring minds want to know!
Thanks,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
You're welcome.
|
|
|
|
|
Luc,
Took your suggestion (kinda) and used regular expressions. Now I just have to get the extensions for all valid image files.
Regex r = new Regex(@"\b\.bmp\b|\b\.png\b|\b\.jpg\b|\b\.jpeg\b|\b\.gif\b");
Match m = r.Match(str);
if (m.Success)
{
img = Image.FromFile(str);
etc.
}
Works like a charm,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|
|
Hi Mike,
I do have three comments on this:
1. file names can be case insensitive (Windows) or sensitive (Unix)
2. there are more image extensions (.TIF, .WMF, .EMF), and the list may grow
3. what if a file holds a valid image but does not carry the appropriate extension?
|
|
|
|