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

  • Home
  • SEARCH
  • 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 4107234
In Process

The Archive Base Latest Questions

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

I am new to programming in C#. I guess it might be a very

  • 0

I am new to programming in C#. I guess it might be a very easy solution which I am not aware of .

Suppose I have a class file

using System;
using System.Collections.Generic;

namespace sharepointproject1
{
    public partial class School
    {
        public students[] students { get; set; }
    }

    public partial class student
    {
        public marks[] marks;
        public extraactivites[] extraactivities;
    }
    public partial class marks
    {
        public int m1 { get; set; }
        public int m2 { get; set; }
    }
    public partial class extraactivities
    {
        public decimal m5;
        public decimal m6;

    }
}

Now in aspx.cs file how do I add marks to the array declared?

namespace sharepointproject1
{
    public partial class testing : usercontrol
    {
        School school = new school();
        protected void Page_Load(object sender, EventArgs e)
        {
            school.students[0].marks[0].mark1 = 45;
        }
    }
}

I need to dynamically add items to it at run time. How do I do that? Do I have to change the array to list array in the class file..Hope I am making some sense out of my question.Later I need to bind the marks to the gridview.

Please help!

  • 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-20T21:28:52+00:00Added an answer on May 20, 2026 at 9:28 pm

    Arrays have a fixed size – use a more flexible collection such as List<T>, which will grow as you need it to.

    Eric Lippert has a good blog post about why arrays should be considered somewhat harmful.

    Additionally:

    • You should look into the .NET naming conventions
    • Only use partial classes when you actually need to, which I suspect you don’t here
    • Don’t expose public fields; use properties instead. However, don’t just expose everything as a property: consider more encapsulation. You don’t necessarily want callers to be able to replace whole collections, but just (say) add or remove students, or access them by index.
    • Consider making some of your classes immutable (most obviously Marks and ExtraActivities)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to programming, and have been banging my head against the
I'm new to audio programming so excuse me if I'm not using the right
I am very new to IOS programming. I have a task to find if
I am new to javascript programming. I have a page on which if Back
Hi I am new to web programming and I have an mvc app which
I am new to programming. I have been trying to write a function in
I'm very new to Perl programming. I've just finished reading the Llama book. Up
i am very new to Programming and i am just reading the documents. For
I have an array being returned but as I'm new to programming I can't
I am pretty new to the ldap based directory service programming using .net framework;

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.