R
RayLopez99
Now that I've learned about 90% of whatever there is to learn about C#
in about six months time, I'm going back and looking at some old
programs I wrote my first month, and seeing where I can improve
efficiency.
One (bad? that's the question) habit I picked up the first month of
coding in C# is found below. My question: is this really a bad habit
or a safe "belt and suspenders" approach?
// here it is:
int[] AnIntegerArray;
int[] ASecondArrayOfInts = new int[2]{1,2};
int Length1 = ASecondArrayOfInts.Length; //needed?
AnIntegerArray = new int[Length1]; //needed?
AnIntegerArray = ASecondArrayOfInts.ToArray();
// can the above few lines - "needed?" - be eliminated (deleted) as
they are already included in:
AnIntegerArray = ASecondArrayOfInts.ToArray(); //?
// I am looking to make a shallow copy of the ASecondArrayOfInts,
which I think is automatically done with .ToArray() (which uses
implicitly 'new'), right?
RL
in about six months time, I'm going back and looking at some old
programs I wrote my first month, and seeing where I can improve
efficiency.
One (bad? that's the question) habit I picked up the first month of
coding in C# is found below. My question: is this really a bad habit
or a safe "belt and suspenders" approach?
// here it is:
int[] AnIntegerArray;
int[] ASecondArrayOfInts = new int[2]{1,2};
int Length1 = ASecondArrayOfInts.Length; //needed?
AnIntegerArray = new int[Length1]; //needed?
AnIntegerArray = ASecondArrayOfInts.ToArray();
// can the above few lines - "needed?" - be eliminated (deleted) as
they are already included in:
AnIntegerArray = ASecondArrayOfInts.ToArray(); //?
// I am looking to make a shallow copy of the ASecondArrayOfInts,
which I think is automatically done with .ToArray() (which uses
implicitly 'new'), right?
RL