|
Yes bool defaults to false and int defaults to 0 if it's a class member variable. I think FxCop/VS code analysis gives warnings if you do try to initialise it, and suggests that it's not necessary.
If it's a private local variable, the compiler won't yet you use it without explicitly initialising it to something. You'll get a "Use of anassigned local variable 'x' error.
Simon
|
|
|
|
|
Thanks for the detailed answer mate, I bet most of us don't know the details
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
bool: false
int: 0
You can find more information in the C# language specification[^], section 5.2 Default values and especially section 4.1.2 Default constructors:
For all simple-types, the default value is the value produced by a bit pattern of all zeros:
For sbyte, byte, short, ushort, int, uint, long, and ulong, the default value is 0.
For char, the default value is '\x0000'.
For float, the default value is 0.0f.
For double, the default value is 0.0d.
For decimal, the default value is 0.0m.
For bool, the default value is false.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you mate
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
Never assume that a variable is automatically initialized. If you want it set to false, then set the damn thing to false.
"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
|
|
|
|
|
Could you please tell me the reason for that? this is very interesting!
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
John said it, don't make assumptions about what it may automatically be initialized to. Especially if you are working on very "critical" software. While on the subject of critical software, you ought to set the warning level to the strictest possible.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I already said it in English, and I don't know any other languages.
If want something to have a default value, assign that value when it's declared. Don't assume the compiler, the framework, or magic elves will automatically do it for you.
"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
|
|
|
|
|
Why not write a little test app to find out? If it is of great concern what it is initialized to, why not just initialize it to whatever you need it to be?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hai i have created pdf from excel the default paper size is potrait but i need the lanscape means i need to change the size of page in pdf i have used acrobat dll can any one help me please
Thanks in Advance
RamyaNaidu
|
|
|
|
|
Hello,
Is there any way to test the internet connection availability.
Thanks.
Dad
|
|
|
|
|
The best thing to do is to use the WebClient object to connect to a known website (like google), and looking for an exception to occur. No exception means you're connected.
bool connected = false;
Uri uri = new Uri("http://google.com");
WebClient webClient = new WebClient();
string response = "";
try
{
response = webClient.DownloadString(uri);
connected = true;
}
catch (Exception ex)
{
if (ex != null) { }
}
"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
modified on Monday, August 4, 2008 8:53 AM
|
|
|
|
|
Hi all,
I recently got the request from a customer to implement an inverse colored version of our winforms application to enhance contrast when using it outdoors. Since the application is quite large implementing this over the whole user interface would be a lot of work. Does anyone know if there's a general system setting I can use to make the application render everything in foto negative colors? I haven't been able to find one, probably because it doesn't exist, but maybe I'm missing something.
Thanks in advance.
Standards are great! Everybody should have one!
|
|
|
|
|
I think there is not such thing. Mabe you can try to switch the global system setting to use high-contrast palette.
You can use WinAPI's SetSysColor() function.
Best regards,
Jaime.
|
|
|
|
|
Tried this, but this only influences the system color pallet, which means it won't work for my app (which uses a custom pallet). Thanks anyway.
Standards are great! Everybody should have one!
|
|
|
|
|
You just need to change the lower palette colors, that are related to the system colors (windows background, caption, border colors, etc)
Best regards,
Jaime.
|
|
|
|
|
I did find these, but I don't see how this helps the overall contrast of my app, since (aside from window captions and border colors) these colors aren't used in my application. Besides, changing these colors means changing the windows overall color scheme, which is not something I want to do to my customers. Thanks again.
Standards are great! Everybody should have one!
|
|
|
|
|
So, you have a custom palette?
Then, what is the problem? You have to define another palette into your application, and let the user switch between them.
Best regards,
Jaime.
|
|
|
|
|
Unfortunately, the good people who designed this application in all their wisdom thought it would be better to just set the colors from the designer. So no, I just have a bunch rgb values in doc file defining what colors should be used where.
Standards are great! Everybody should have one!
|
|
|
|
|
in windows XP:
Control Panel -> Accessibility Options -> Display (tab) -> Use High Contrast (Tick box)
Simon
|
|
|
|
|
Thanks, but that's not really what I meant, I just wanted to set high contrast colors for a single app. Besides, I'm not using the default system color panel, so this won't work with my application.
Standards are great! Everybody should have one!
|
|
|
|
|
Bekjong wrote: I just wanted to set high contrast colors for a single app
Oh, in that case, I don't think there is a easy setting you can change.
Bekjong wrote: I'm not using the default system color panel, so this won't work with my application.
Double ohh, Now there defiantly isn't a setting for it.
It is winforms or wpf?
Simon
|
|
|
|
|
It's Forms. Thanks again.
Standards are great! Everybody should have one!
|
|
|
|
|
You could look into the possibility of writing a custom control, that took the colour beneath each point in the surface, and inverted it. Effectively acting like a inversion filter, so you'd just display the control over the top of each of the apps form.
Not sure how easy/hard this would be, or even if possible.
Simon
|
|
|
|
|
I don't think it will work by putting new controls over old ones, but you did bring me to an idea:
I could use reflection to find all controls in my app, then find each field of type Color and invert it. That might do the trick. Think it will work?
Thanks for the inspiration.
Standards are great! Everybody should have one!
|
|
|
|