SolwayFirth
SolwayFirth
CC#
Created by SolwayFirth on 4/7/2023 in #help
✅ variables declared with/without the “new” keyword.
What difference does using the word new make in the code? even in terms of memory allocations n stuff. also in this code how many TrialObjects objects were created?
TrialObjects testObj1 = new TrialObjects("some string argument1");
TrialObjects testObj2 = new TrialObjects("some string argument2");
TrialObjects testObj3 = testObj1;
TrialObjects testObj1 = new TrialObjects("some string argument1");
TrialObjects testObj2 = new TrialObjects("some string argument2");
TrialObjects testObj3 = testObj1;
23 replies
CC#
Created by SolwayFirth on 3/7/2023 in #help
❔ Fix sized array/list
I'm quite new to C#, evidently, and I'm trying to initialise a list (or an array) in a class that shall be defined when an instance of this class is made. Something like:
class Testing {
Private int[] _cords = new int[2];

Public Testing(int num1, int num2) {
_cords = {num1, num2};
}
}
class Testing {
Private int[] _cords = new int[2];

Public Testing(int num1, int num2) {
_cords = {num1, num2};
}
}
this code is ofcourse wrong, but I believe it should kinda explain what im trying to do.
38 replies