|
So see this [^] thread of yourself!
|
|
|
|
|
Oh CPallini is our friend on the c++ forum.
|
|
|
|
|
Those books are good recommendations. Anything by Richter is a good bet. Also get Effective C# by Bill Wagner, Addison-Wesley, $40. 50 advanced topics with concise mundane treatment. No stupid jokes or silly pictures.
|
|
|
|
|
Really a 1? someone not a Richter or Marshall fan?
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
If you like you can search with this title "programmer's heaven c# school" I read this book and I think its good book for your friend (of course I think c# is difficult than VB) I dont know C# is simple for me or its simple for all people specialy for memory management (I am working wtih c++)
Good luck!
|
|
|
|
|
Is there a way to determine the measurement units for a given locale using CultureInfo class or some other item in the framework?
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Not that I know of - a quick check of MSDN and it seems that setting is mysteriously missing from the CultureInfo class where one would expect it... however what kind of "measurement units" do you need? Just, for example, metric vs imperial units? (the setting for "Metric" or "U.S."
If so, I'd recommend just giving the user the choice, or if it's not an application where that "makes sense", I'd personally be quite comfortable with hardcoding it to:
US = US imperial units
Liberia = US imperial units
Burma = US imperial units
UK = Depends on types of units you're talking about, maybe imperial, maybe metric (officially metric, but they're a strange bunch!)
Anywhere else = Metric units
If you're talking about other measurement, such as how to display the date string or currency or whatever, you CAN get that from CultureInfo, but I guess you already knew that...
|
|
|
|
|
Ok, just as I thought. I have to do temperature conversions, not really a taxing affair but I like to do things in an extensible way. I have done a fairly substantial internationalization project before, but the units were specified by the company as some industry specific types, that had only one exception for Russia. I just coughed up the unit value and let the rest of the formatting be done by the CultureInfo class. Getting the measurement units would be a nice addition to that class.
I'll probably hard code or maybe derive a custom CultureInfo type to include your list. Thanks for the info, I appreciate the help.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
I stand corrected . That information is available in the RegionInfo class as it has an IsMetric property. I guess it makes sense if you think about the difference between what CultureInfo and RegionInfo should represent. Never thought to look in there... I almost never use that class.
Thanks again.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Thanks for finding that - I'll keep it in mind if I ever need it! (which is quite possible, as I also often work on "International" projects - just haven't had that particular requirement yet)
|
|
|
|
|
Hello everyone,
I have 3 basic questions about Enum, from MSDN,
http://msdn.microsoft.com/en-us/library/sbbt4032(VS.80).aspx
1.
It is mentioned "A variable of type Days can be assigned any value in the range of the underlying type;" -- I think it is not correct to say any value in the range of the underlying type, like integer, but in the range from Sat to Fri.
For example, you can not write Days d = 65535;
2.
"and if additional elements have been added to the enum type, the test for default values can return true unexpectedly." I do not quite understand this scenario, could anyone show me some code please?
3.
"You can notice these changes when using tools such as the Console class methods, the Expression Evaluator, and so forth. (See example 3).", I have tried example 3. But what are the rules for the changes when we add System.FlagsAttribute? The document only says there will be some changes, but not clearly states what will be the changes. Any ideas?
thanks in advance,
George
|
|
|
|
|
Hi
In the MSDN enum was declare as follow "The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list"
1.
you need to understand that at the bottem line there is a native variable like int or short that can hold other values.
for example:
Days d = (Days)int.MaxValue;
2.
"Assigning additional values new versions of enums, or changing the values of the enum members in a new version, can cause problems for dependant source code. It is often the case that enum values are used in switch statements, and if additional elements have been added to the enum type, the test for default values can return true unexpectedly."
in case that you are using flags for bitwaise operation,
if one or more enum value was changed you need to update your program
to prevent unwanted if results
|
|
|
|
|
Thanks nissims,
Some further questions/comments.
1.
If we write an Enum variable like d in my code, and assign it beyond the related int range from Sat to Fri, does such code have any practical usage? I think people always use the values in the range and treat the ones beyond the range as invalid values.
2.
I do not quite understand what do you mean "in case that you are using flags for bitwaise operation", could you show me some pseudo code please?
regards,
George
|
|
|
|
|
1.you are right the all purpose of enum is to give
you the ability to use some logical const names insetd of numbers
for example
enum Days { Sat = 1, Sun, Mon, Tue, Wed, Thu, Fri }
vs
1,2,3,4,5,6,7
there for it is not wise to override the enum consts using numbers
if the enum was declared use it, specially if you need to cast it in order to use numbers.
2.Please read the "using flags attribute" in the msdn article.
|
|
|
|
|
|
Any practical usage? There's probably something, but i can't think of anything.
And on to flags:
[Flags]
public enum MyKeys : int
{
Null = 0,
Up = 0x01,
Down = 0x02,
Left = 0x04,
Right = 0x08
}
...
MyKeys keys = MyKeys.Up | MyKeys.Right;
if((keys&MyKeys.Right) == MyKeys.Right)
MessageBox.Show("keys contains MyKeys.Right!");
Each value in the enum represents 1 bit:
0x01 = 0001
0x02 = 0010
0x04 = 0100
0x08 = 1000
So if we use the bitwise operators OR and AND we can add and check for these bits. In the above code:
MyKeys keys = MyKeys.Up | MyKeys.Right;
is the same as
MyKeys keys = 0001 | 1000;
keys is now 1001
keys&MyKeys.Right
is the same as
1001&1000 and the result is 1000
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks SK Genius,
My current confusion is, when add or remove flags attribute, the result is always the same. So I am wondering the special usage of the attribute compared with the situation when we do not use it.
Here is my test code, any comments?
using System;
class Test
{
enum Days
{
Mon = 1,
Tue = 2
};
[Flags]
enum DaysFlag
{
Mon = 1,
Tue = 2
};
static void Main()
{
int a = (int) (Days.Mon | Days.Tue);
int b = (int)(DaysFlag.Mon | DaysFlag.Tue);
return;
}
}
regards,
George
|
|
|
|
|
Hi,
I have two bytes which I need to obtain the sum of them.
I have done like this but the result is wrong.
int result = byte[1] + byte[2];
How can I do that?
Thanks in advanced
Merh
|
|
|
|
|
merh wrote: I have done like this but the result is wrong.
Sure? How did you check the result?
Please post code, inputs and ouput.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I have an array of bytes. s below is my array and I try to read byte nr 0 and add to nr 1.
for(int i=0; i<=1; i++)
int result += s[i];
Thanks
Merh
|
|
|
|
|
What are the values of s[0] and s[1] ? What is the value of result produced by the code? What are you expecting result to be?
You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always got punched out when I reached 4....
-- El Corazon
|
|
|
|
|
do you mean something similar to:
int i;
byte[] s ={ 10, 20 };
int result=0;
for (i = 0; i <= 1; i++)
result += s[i];
though inelegant, I see no error in the above.
On the other hand, your code, ss it stands, doesn't even compile.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Yes, I mean something like this
int i;
byte[] s ={ 10, 20 };
int result=0;
for (i = 0; i <= 1; i++)
result += s[i];
|
|
|
|
|
Well it works fine on my system and since you have provided no inputs and no output I can only guess what is happening on yours.
Should I turn ON my Code Project Mind Reader Unit?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks it works now on my system too.
/Mehran
|
|
|
|