does anyone know how to resolve this?

???
11 Replies
𓀠𓀒𓀡𓀬
using System; using System.Data; using System.Linq.Expressions; using System.Net.Security; using System.Diagnostics; using System.IO; using System.ComponentModel.DataAnnotations; using System.Xml.Schema; namespace Program; class Bird { public string color; public int amount; public Bird(string color_bird, int amount_bird) { color = color_bird; amount = amount_bird; } static void Main(string[] args) { Random random = new Random(); string[] parrots = { "Parrot", "Ara", "Sun conure", "Lovebird", "Cockatoo", "Macaws", "Lorikeets", "Scarlet Macaw", "Kākāpō", "Parakeets", "Senegal parrot", "Caiques", "Amazon parrot", "Parrotlet", "Burrowing parrot", "Cockatiel", "African Grey", "Eclectus", "Pionus parrot", "Budgerigar", "African Greys" }; string[] colors = { "Blue", "Red", "Green" }; for (int i = 0; i < parrots.Length; i++) { int num = random.Next(); int start = random.Next(0, colors.Length); Bird parrots[i] new Bird(colors[start], num); Console.WriteLine(parrots[i].color); Console.WriteLine(parrots[i].amount); } } }
kpang5812
kpang58124mo ago
Bird parrots[i] new Bird(colors[start], num);
Bird parrots[i] new Bird(colors[start], num);
logical error with this code.
i like chatgpt
i like chatgpt4mo ago
class Bird
{
public string color;
public int amount;

public Bird(string color_bird, int amount_bird)
{
color = color_bird;
amount = amount_bird;

}
static void Main(string[] args)
{
Random random = new Random();
string[] parrots = { "Parrot", "Ara", "Sun conure", "Lovebird", "Cockatoo", "Macaws", "Lorikeets", "Scarlet Macaw", "Kākāpō", "Parakeets", "Senegal parrot", "Caiques", "Amazon parrot", "Parrotlet", "Burrowing parrot", "Cockatiel", "African Grey", "Eclectus", "Pionus parrot", "Budgerigar", "African Greys" };
string[] colors = { "Blue", "Red", "Green" };

Bird[] birds = new Bird[parrots.Length];

for (int i = 0; i < parrots.Length; i++)
{
int num = random.Next();
int start = random.Next(0, colors.Length);

birds[i] = new Bird(colors[start], num);
Console.WriteLine(birds[i].color);
Console.WriteLine(birds[i].amount);
}
}
}
class Bird
{
public string color;
public int amount;

public Bird(string color_bird, int amount_bird)
{
color = color_bird;
amount = amount_bird;

}
static void Main(string[] args)
{
Random random = new Random();
string[] parrots = { "Parrot", "Ara", "Sun conure", "Lovebird", "Cockatoo", "Macaws", "Lorikeets", "Scarlet Macaw", "Kākāpō", "Parakeets", "Senegal parrot", "Caiques", "Amazon parrot", "Parrotlet", "Burrowing parrot", "Cockatiel", "African Grey", "Eclectus", "Pionus parrot", "Budgerigar", "African Greys" };
string[] colors = { "Blue", "Red", "Green" };

Bird[] birds = new Bird[parrots.Length];

for (int i = 0; i < parrots.Length; i++)
{
int num = random.Next();
int start = random.Next(0, colors.Length);

birds[i] = new Bird(colors[start], num);
Console.WriteLine(birds[i].color);
Console.WriteLine(birds[i].amount);
}
}
}
𓀠𓀒𓀡𓀬
uhm o i see bruh thx
i like chatgpt
i like chatgpt4mo ago
don't forget to type /close and press enter.
𓀠𓀒𓀡𓀬
/close
i like chatgpt
i like chatgpt4mo ago
@Winter dissi Another simpler one:
string[] parrots = { "Parrot", "Ara", "Sun conure", "Lovebird", "Cockatoo", "Macaws", "Lorikeets", "Scarlet Macaw", "Kākāpō", "Parakeets", "Senegal parrot", "Caiques", "Amazon parrot", "Parrotlet", "Burrowing parrot", "Cockatiel", "African Grey", "Eclectus", "Pionus parrot", "Budgerigar", "African Greys" };
string[] colors = { "Blue", "Red", "Green" };
var birds = new Bird[parrots.Length];
for (int i = 0; i < parrots.Length; i++)
{
int num = Random.Shared.Next();
int start = Random.Shared.Next(0, colors.Length);

birds[i] = new Bird(colors[start], num);
Console.WriteLine(birds[i].Color);
Console.WriteLine(birds[i].Amount);
}

class Bird(string color, int amount)
{
public string Color { get; set; } = color;
public int Amount { get; set; } = amount;
}
string[] parrots = { "Parrot", "Ara", "Sun conure", "Lovebird", "Cockatoo", "Macaws", "Lorikeets", "Scarlet Macaw", "Kākāpō", "Parakeets", "Senegal parrot", "Caiques", "Amazon parrot", "Parrotlet", "Burrowing parrot", "Cockatiel", "African Grey", "Eclectus", "Pionus parrot", "Budgerigar", "African Greys" };
string[] colors = { "Blue", "Red", "Green" };
var birds = new Bird[parrots.Length];
for (int i = 0; i < parrots.Length; i++)
{
int num = Random.Shared.Next();
int start = Random.Shared.Next(0, colors.Length);

birds[i] = new Bird(colors[start], num);
Console.WriteLine(birds[i].Color);
Console.WriteLine(birds[i].Amount);
}

class Bird(string color, int amount)
{
public string Color { get; set; } = color;
public int Amount { get; set; } = amount;
}
𓀠𓀒𓀡𓀬
🙂