© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
22 replies
!Adiin

❔ Classes

Hello
using System;
Class Program{

       Public static void main(string[] args) {

                Employee[] employees = new employees[10];

             //can I make like this:
             for (int i = 0;i < employees. length;i ++) {
employees[i] = new employees[i, "Name" ];
} 

     } 
}

Public class Employee {
           private int Id;
           private string name;
          Public Employee(int Id, string Name) {
                this.Id = Id;
                this.Name = Name;     
         } 

}
using System;
Class Program{

       Public static void main(string[] args) {

                Employee[] employees = new employees[10];

             //can I make like this:
             for (int i = 0;i < employees. length;i ++) {
employees[i] = new employees[i, "Name" ];
} 

     } 
}

Public class Employee {
           private int Id;
           private string name;
          Public Employee(int Id, string Name) {
                this.Id = Id;
                this.Name = Name;     
         } 

}

Is the command inside for loop works??
I think no
How can I add values to the classes in array?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

classes
C#CC# / help
3y ago
Classes
C#CC# / help
4y ago
Constructors, Classes
C#CC# / help
16mo ago
Internal classes
C#CC# / help
2y ago