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 1041133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:18:40+00:00 2026-05-16T15:18:40+00:00

I am a rookie to C# and here is my question class myClass {

  • 0

I am a rookie to C# and here is my question


class myClass
{
    int start;
    int end;
    .......
}


class program
{

    public void main()
    {

        myClass[] a= new myClass[10];
        for (int i = 1; i < a.length; i++)
        {
           myClass b = new myClass();
           a[i] = b;
           a[i].start = 1;
           ...  (keep populating)
           ...
        }
           console.writeline(a[1].start)       // NO PROBLEM WITH THIS LINE, THE VALUE WAS OUTPUTED
        subMethod(a);
    }

    public void subMethod(myClass[] a)
    {
        console.write(a[1].start);         // NO PROBLEM WITH THIS LINE, OUTPUT NORMALLY
        for (int i = 1; i < a.length, i++)
        {
            int h = a[i].start;            ????? OBJECT NOT INSTANTIATED
        }
    }
}

The error is as indicated above and I have difficulty to understand it. Anyone can help me out. Thanks in advance

  • 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-16T15:18:40+00:00Added an answer on May 16, 2026 at 3:18 pm

    Please post code that compiles. The error is probably in your transcribing of the code, because this code works perfectly fine:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace RandomArrayTest
    {
        class MyClass
        {
            public int start;
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                MyClass[] a = new MyClass[10];
                for(int i=1; i<a.Length; i++)
                {
                    MyClass b = new MyClass();
                    a[i] = b;
                    a[i].start = 1;
                }
    
                MyFunction(a);
            }
    
            static void MyFunction(MyClass[] a)
            {
                for (int i = 1; i < a.Length; i++)
                {
                    int h = a[i].start;
                    Console.WriteLine(h);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rookie question, I think. I'm just trying to replicate this: http://rpubs.com/gallery/googleVis Open a new
Probably really a rookie question here about xcode (for the iphone).. When I issue
this may be a rookie question for CakePHP but here it goes I design
Rookie JS question here: for( var p in ['nodeName', 'nodeType', 'tagName', 'localName'] ) {
everyone. I have a rookie question about the returning value in java. Here's my
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
I'm pretty much the rookiest rookie when it comes to Flash. Here's the actionscript
This is obviously a rookie question about Adobe technologies, but I am seeking a
rookie here. i am using basic javascript, css to open/close div by clicking/unclicking on
This should be really simple but I'm a javascript/jQuery rookie, so here we go:

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.