C# is supposed to be an improvement over C++, and I've read a zillion
debates on using "using", no "typedef", no "include" to no avail. So
how can I implement data dictionary-like functionality in C#? I must
be missing something.
Let's say I want to create a class "Animal" that contains a field
"nLegs" that contains the number of legs, and "nEyes" that contains the
number of eyes. I want all of my code to declare variables that contain
the number of legs by the same type, and variables that count the
number of eyes by a (possibly) different type. (Or forget classes..
let's say that I just want to declare all of my eye-counter and
leg-counter variables consistently throughout all of my programs.) Now,
I initially think "int" will work for the number of legs and eyes. In
C++, of course, I put:
typedef int LEGS;
typedef int EYES;
in an #include'd .h file. Then in my code, I put:
#include <mytypes.h>
:
LEGS nLegs;
EYES nEyes;
and so on.
But sometime later I discover that there are animals with fractional
legs (go with me on this...) so I want to change all of my leg-counting
variables to float. So when I discovered the half-legged animals, I
just changed over to:
typedef float LEGS;
in one place (my .h file), and didn't have to worry about synchronizing
a zillion instances throughout all my modules.
How can I achieve the very same functionality in C#? Of course, my
project uses several source files, so just pasting the same bunch of
"using"s at the top of each one won't cut it. A class isn't really what
I want, either, I don't think. Ideas??
....R