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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:36:22+00:00 2026-05-18T10:36:22+00:00

I am passing a IList into another class which looks as follows: public class

  • 0

I am passing a IList into another class which looks as follows:

public class KundenViewModel
{
    public IList<Kunde> _kunden;

    /// <summary>
    /// Add a list of Kunde to the View
    /// </summary>
    /// <param name="kunden">A list of Kunde objects</param>
    public KundenViewModel(IList<Kunde> kunden)
    {
        foreach (var k in kunden)
        {
            var test = k._Name;
            _kunden.Add(k);
        }
        //_kunden.AddRange(kunden);
    }

    /// <summary>
    /// Add one Object of Kunde to the View
    /// </summary>
    /// <param name="kunde">A Kunde Object</param>
    public KundenViewModel(Kunde kunde)
    {
        _kunden.Add(kunde);
    }
}

But at runtime I receive at the Line 14 (_kunden.Add(k);) the error “Object reference not set to an instance of an object.” Well I would say the object has never been initialized, but It has been and I also can access the properties for example the line before, there is no error.

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-18T10:36:23+00:00Added an answer on May 18, 2026 at 10:36 am

    Have you initialized _kunden list?

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

Sidebar

Related Questions

I have a class as follows: public class ABC { public IList<TextFillerDetail> TextFillerDetails {
I have a class with a Items property, which is an IList: class Stuff
I have a viewmodel called ArticleAdmin that includes a list of checkboxes: public class
I'm passing IList<Post> to View(posts) . Post is a linqToSql generated model class. Post
This throws error: public static void RenderPartialForEach<T> (this HtmlHelper helper, string partialName, IList<T> list)
My controller is passing through a list which I then need to loop through
Currently, I have: public static IList getFilteredEvents( DateTime Start, DateTime End, string env, string
I'd like to have the following setup: class Descriptor { public string Name {
[WebMethod(Description = Return all activities by Task.)] public IList<ActivityDto> GetActivitiesByTaskID(int taskID) { IList<Activity> activities
Passing value to another xaml page can be done easily with NavigationService.Navigate(new Uri(/SecondPage.xaml?msg= +

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.