• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

New Programmer Assistance Here- C#

As already suggested, you really should take the trouble to teach yourself the basics of C# before asking more questions. Your new problem seems to be the same as your old problem with the same answer.
 
Agreed - the problem is that you are putting everything into the Animal class as we discussed before.
 
Otherwise C# is in the group of languages that have a managed memory model. In theory the programmer should not need to worry about recovering unused and memory. C, C++ memory management and garbage collection is left to the developer

OT but every time my Android memory usage starts climbing because of some app that has a memory leak I want to curse the lack of alertness that managed memory has caused in so many programmers....and wish that they actually would master the art of C++ and pointers.
 
Last edited:
OT but every time my Android memory usage starts climbing because of some app that has a memory leak I want to curse the lack of alertness that managed memory has caused in so many programmers....and wish that they actually would master the art of C++ and pointers.

Very true. The idea that you can ignore memory management in so called managed code is just plain wrong..............
 
Very true. The idea that you can ignore memory management in so called managed code is just plain wrong..............

Trouble is that with these safety nets, we get sloppy about how we walk the tightrope. Not having used C#, but reasonable with C++ (I developed some medical systems in C++ that used VM a great deal) I'll obviously have to read up about managed memory. I did use Java a little, but not in any application that needed to manipulate large data sets in VM (for speed), but in C++, for those medical programs, I learned to watch allocation/deallocation like a hawk.

Sadly I'm of the age where I can reall being told to write a real-time program to gather some stats from up to 4000 outstations (urban traffic control), activated once per second from a timer, and to cap it all being told that since this was memory resident I had about 400 words allocated to it. Using Coral 66 at the time (Ferranti Argus!), I learned a lot about anonymous referencing because it saved a few words of memory and got close to machine code in efficiency. So it was that kind of picky environment in which I got started and, frankly, it did me great good.

This also means I'm of the age where I hear about managed memory and my first instinct is "hmm, should I trust it?". :)
 
Now Im a new person to all this coding buisness and i would like some Help

A better/cleaner approach to initialize a class and derive from it, it's using constructors:

This is the base class:
Code:
public class Aircraft
{
    public string TypeOfPlane;
    public string Model;
    public int PilotsRequired;
    public int FuelLimit;
    public int Price;

    public Aircraft(string typeOfplane, string model, int pilotsRequired, int fuelLimit, int price)
    {
        TypeOfPlane = typeOfplane;
        Model = model;
        PilotsRequired = pilotsRequired;
        FuelLimit = fuelLimit;
        Price = price;
    }

}

Here, we derive a JetAircraft class from the base Aircraft class. This means a JetAircraft class already contain all members variables and functions of the Aircraft class, so you only need to add new ones specific to the JetAircraft.

The constructor is a special method in a class that has the same name of the class itself, which is called automatically when the class is instantiated.

Code:
public class JetAircraft : Aircraft
{
    public int NumOfJetEngines;

    public JetAircraft( string typeOfplane, string model, int pilotsRequired, int fuelLimit, int price, int numOfJetEngines)
        : base( typeOfplane, model, pilotsRequired, fuelLimit, price )
    {
        NumOfJetEngines = numOfJetEngines;
    }
}
Note the use of the : base( ..., ... ) keyword, to call the constructor of the base class. This means that, when you declare a new variable of the JetAircraft type, the compiler will first call the constructor of the base Aircraft class, passing the first 5 parameters to it, and then it will use the 6th parameter to call its own constructor, to initialize the new member variable that exists only in the JetAircraft class.

And here, we create two instance variables of the two classes, note the first use 5 parameters, the 2nd one use 6.

Code:
class Program
{
    static void Main(string[] args)
    {
        Aircraft aircraftC172 = new Aircraft("Cessna", "172", 1, 1, 10);
        JetAircraft aircraftB747 = new JetAircraft("Boeing", "747", 3, 10, 300, 4);
    }
}

The whole point of using constructors, is that if you forget to initialize something, the program will not even COMPILE, so you catch potential bugs before they have a chance to happen.
 
Last edited:
Well anyway I will be starting over for the third time to try and understand coding but for Now I will try to sort things out get my schedule organized and then ill start.

Thanks guys! Didn't Mean to bother
 
Back
Top