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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:25:59+00:00 2026-05-24T08:25:59+00:00

I have a relatively deep object tree in C# that needs to be initialized

  • 0

I have a relatively deep object tree in C# that needs to be initialized from IronPython.

I’m new to python and I’m struggling with the initialization of arrays.

So as an example – say I have these classes in C#

public class Class1
{
    public string Foo {get;set;}
}

public class Class2
{
    List<Class1> ClassOnes {get;set;}
}

I can initialize the array in Class2 like so:

var class2 = new Class2(
    ClassOnes = new List<Class1>()
    {
        new Class1(Foo="bar")
    });

In IronPython – I was trying this:

bar = Class2
bar.ClassOnes = Class1[Class1(Foo="bar")]

But I always get this message:

expected Array[Type], got Class1

Any ideas?

  • 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-24T08:25:59+00:00Added an answer on May 24, 2026 at 8:25 am

    Made a mistake on the Class2() — that’s what I get for making an example instead of posting real code!!!

    For what it’s worth – I was able to initialize the List with actual instances like this:

    from System.Collections.Generic import List
    
    bar.ClassOnes = List[Class1]([Class1(Foo="bar")])
    

    Thanks much Cameron!

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

Sidebar

Related Questions

I am relatively new Java developer that's been thrown in the deep end, my
I'm working with some classes which, when throwing, have a relatively deep InnerException tree.
I have a relatively simple site that I'm working up for an intranet environment.
We have are relatively simple Reporting Services report that our users commonly export to
I have a relatively simple select statement in a VB6 program that I have
I have a relatively small app that Im building using vb.net 2.0, and nant.
I have a relatively large database tables (just under a million rows) that has
I have a relatively small Java library that implements a few dozen beans (no
I'm relatively new to .NET and have being using Linq2Sql for a almost a
I have a relatively large dataset of items (a few thousand items) that I

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.