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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:19:04+00:00 2026-06-04T07:19:04+00:00

I am a new developer to c# MVC3. I have a problem that I

  • 0

I am a new developer to c# MVC3.
I have a problem that I cannot create object that contains arrays of property inside object.

For example, I want to create instance ABC.Property[] for 10 arrays.

ABC.Property[0]

ABC.Property[1]

ABC.Property[2]
…..
….
ABC.Property[10]

I used debug mode to check and found out that ABC.Property[] is null. So i cannot add the value back to that object’s array.

How to crate object with propeties’s array?

thank you.

namespace finance3.Models
{
public class Expected_and_Risk
{


    public decimal[] Prop { get; set; }
    public decimal[] Forecast { get; set; }
    public string[] Name { get; set; }
    public decimal[] AxB { get; set; }
    public decimal[] PowAxB { get; set; }


    public decimal  ExpectValue(Expected_and_Risk abc)
    {

        decimal count = abc.Forecast.Count();

        Expected_and_Risk Result = new Expected_and_Risk();

        for (int i = 0 ; i < count ; i++)
        {
            // here is the problem
            // i cannot add new data to array because it has no dimemsion and i tried this
            //
            // Expected_and_Risk[] Result = new Expected_and_Risk[10];
            //
            // but it didn't work

            Result.Name[i] = abc.Name[i];
            Result.Prop[i] = abc.Prop[i];
            Result.Forecast[i] = abc.Forecast[i];
            Result.AxB[i] = abc.Prop[i] * abc.Forecast[i];


            decimal a = Result.AxB[i];
            decimal sumAxB =+ a;

            double temp = (double)(a * a) ;
            Result.PowAxB[i] = (decimal)(temp);

        }

        return Convert.ToDecimal(Result); 
    }
}

}
  • 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-06-04T07:19:05+00:00Added an answer on June 4, 2026 at 7:19 am

    Better way could be to add following method into Expected_and_Risk class and call it from within constructor.

    EDIT – edit is done to make Initialize private, and call it within constructor.

    void Initialize(int size)
    {
        Prop = new decimal[size];
        AxB = new decimal[size];
        Forecast = new decimal[size];
        PowAxB = new decimal[size];
        Name = new string[size];
    }
    
        public Expected_and_Risk(int size)
        {
          ....
          Initialize(size);
        }
    

    After that use it in ExpectValue like

    Expected_and_Risk Result = new Expected_and_Risk(size)// size is 10 in example;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a new developer that is just now learning LinqToSql. While going over
I have developed a MVC3 application in that I want use the Check boxlist
I am a new developer on Android and I want store user data in
What are the concepts that must be known by a new Perl developer for
I'm working on a new Asp.Mvc3 application that will go line about the same
im new developer and making my firt iPhone app ,and i want to make
I am not a new developer to android. I have an application on the
I have develop small Asp.net MVC3 application using Telerik rad Controls with in that
I am new to silverlight and want to learn silverlight. I have installed Visual
I've been reading about the new developer-only RC0 for Silverlight, and the fact that

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.