Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:20:31+00:00 2026-05-27T21:20:31+00:00

I have: partial class StarSystem : AstroThreeNode { public static StarSystem SunSolarSystem() { return

  • 0

I have:

partial class StarSystem : AstroThreeNode
{
    public static StarSystem SunSolarSystem()
    {
        return new StarSystem("Solar System", Planet.SunCenter(), Resources.Space, SolarSystem.ActiveForm.Bounds).AddPlanet(Planet.MercuryPlanet(), Planet.VenusPlanet(), Planet.EarthPlanet(), Planet.MarsPlanet(), Planet.JupiterPlanet(), Planet.SaturnPlanet(), Planet.UranusPlanet(), Planet.NeptunePlanet());
    }

    public StarSystem AddPlanet(params Planet[] planetsToAdd)
    {
        foreach (Planet planet in planetsToAdd)
        {
            distanceFromSun += (planets.Count > 0 ? planets[planets.Count - 1].Image.Width / 2 : 0) + planet.Image.Width / 2 + DISTANCE_BETWEEN_PLANETS;
            planet.DistanceFromSun = distanceFromSun;
            planet.RotationCenter = new PointF(bounds.Width / 2, bounds.Height / 2);
            planets.Add(planet);
        }
        return this;
    }
}


partial class Planet : AstroThreeNode
{
    private const float SUN_SPEED = 0;
    public static Planet SunCenter() 
    {
        return new Planet("Слънце", Resources.Sun_, SUN_SPEED, CLOCKWISE);
    }
    public static Planet MercuryPlanet()
    {
        return new Planet("Меркурий", Resources.Mercury_, 4.0923f, Planet.CLOCKWISE);
    }
    public static Planet VenusPlanet()
    {
        return new Planet("Венера", Resources.Venus_, 1.6021f, Planet.COUNTERCLOCKWISE);
    }
    public static Planet EarthPlanet()
    {
        return new Planet("Земя", Resources.Earth_, 0.9856f, Planet.CLOCKWISE);
    }
    public static Planet MarsPlanet()
    {
        return new Planet("Марс", Resources.Mars_, 0.5240f, Planet.CLOCKWISE);
    }
    public static Planet JupiterPlanet()
    {
        return new Planet("Юпитер", Resources.Jupiter_, 0.0830f, Planet.CLOCKWISE);
    }
    public static Planet SaturnPlanet()
    {
        return new Planet("Сатурн", Resources.Saturn_, 0.0334f, Planet.CLOCKWISE);
    }
    public static Planet UranusPlanet()
    {
        return new Planet("Уран", Resources.Uranus_, 0.0117f, Planet.COUNTERCLOCKWISE);
    }
    public static Planet NeptunePlanet() 
    {
        return new Planet("Нептун", Resources.Neptune_, 0.0059f, Planet.CLOCKWISE);
    }

    public Planet(string name, Image image, float distanceFromSun, float degreesAddedEachTick, bool clockwise, PointF rotationCenter, float angleInDegrees = 0)
    {
        this.Name = name;
        this.Image = image; // here I set the Image but I get an exception later
        this.DistanceFromSun = distanceFromSun;
        this.degreesAddedEachTick = degreesAddedEachTick;
        this.isClockwiseRotation = clockwise;
        this.RotationCenter = rotationCenter;
        this.angleInDegrees = angleInDegrees;
    }
}

I get the exception here: distanceFromSun += (planets.Count > 0 ? planets[planets.Count - 1].Image.Width / 2 : 0) + planet.Image.Width / 2 + DISTANCE_BETWEEN_PLANETS;
For the planet.Image. I don’t get it why do I get exception when I set the Image when I create a Planet.

EDIT: Here is the constructor for StarSystem :

    public StarSystem(string name, Planet starSystemCenter, Image background, Rectangle bounds)
    {
        this.Name = name;
        this.Background = background;
        this.bounds = bounds;
        planets = new List<Planet>(); //planets instanieted here
        planets.Add(starSystemCenter); // note I dont get the exception on this call but on the other call where I add all other planest
    }

EDIT 2:
Found my problem but I have to go to bed I will post the answer tomorrow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:20:32+00:00Added an answer on May 27, 2026 at 9:20 pm

    Try to have class members, local variables, and method parameters differ by more than capitalization. See Bad Naming Convention in the canonical NullReferenceException post linked above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
I have this c# user control class: public partial class UserControls_JsTop : System.Web.UI.UserControl {
if i have public partial class MyLittlePage: System.Web.UI.Page {... and i have overriden for
I have the following code: Imports System.Data Partial Class Students_AddWishes Inherits System.Web.UI.Page Public dt
I have public partial class MainWindow : Window Also I have got some static
say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock
I have a control that is created like so: public partial class MYControl :
I have a program that looks something like this: public partial class It {
I have a page that is setup like this public partial class _Default :
Suppose I have an entity object defined as public partial class Article { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.