Dictionary<TKey, TValue>.Human.getNameAndAge is a method, so you need to invoke it like one:
Dictionary<TKey, TValue>System.Func`1[System.Collections.Generic.Dictionary`2[System.String,System.Int32]]Bob's age is 18 and he has connected.
Bobby's age is 16 and he has connected.
Bibby's age is 11 and he has connected.
3
System.Func`1[System.Collections.Generic.Dictionary`2[System.String,System.Int32]]Human.getNameAndAgeConsole.WriteLine(Human.getNameAndAge());Bob's age is 18 and he has connected.
Bobby's age is 16 and he has connected.
Bibby's age is 11 and he has connected.
3
System.Collections.Generic.Dictionary`2[System.String,System.Int32]System.Func`1[System.Collections.Generic.Dictionary`2[System.String,System.Int32]]
System.Collections.Generic.Dictionary`2[System.String,System.Int32]Human bob = new Human("Bob", 18);
Human bobby = new Human("Bobby", 16);
Human bibby = new Human("Bibby", 11);
Console.WriteLine(Human.objectCount);
Console.WriteLine();
Console.ReadLine();
class Human
{
private string name { get; set; }
private int age { get; set; }
public static int objectCount;
static Dictionary<string, int> nameAndAge = new Dictionary<string, int>();
public Human(string name, int age)
{
this.name = name;
this.age = age;
objectCount++;
Console.WriteLine($"{this.name}'s age is {this.age} and he has connected.");
nameAndAge.Add(name, age);
}
public Dictionary getNameAndAge() // the error is here, how do i return a dictionary via a function?
{ //
return nameAndAge; //
} //
}Human bob = new Human("Bob", 18);
Human bobby = new Human("Bobby", 16);
Human bibby = new Human("Bibby", 11);
Console.WriteLine(Human.objectCount);
Console.WriteLine(Human.getNameAndAge);
Console.ReadLine();
class Human
{
private string name { get; set; }
private int age { get; set; }
public static int objectCount;
static Dictionary<string, int> nameAndAge = new Dictionary<string, int>();
public Human(string name, int age)
{
this.name = name;
this.age = age;
objectCount++;
Console.WriteLine($"{this.name}'s age is {this.age} and he has connected.");
nameAndAge.Add(name, age);
}
public static Dictionary<string, int> getNameAndAge()
{
return nameAndAge;
}
}Console.WriteLine(bob.getNameAndAge)Human.getNameAndAge()Human bob = new Human("Bob", 18);
Human bobby = new Human("Bobby", 16);
Human bibby = new Human("Bibby", 11);
Console.WriteLine(Human.objectCount);
Console.WriteLine(Human.getNameAndAge());
Console.ReadLine();
class Human
{
private string name { get; set; }
private int age { get; set; }
public static int objectCount;
static Dictionary<string, int> nameAndAge = new Dictionary<string, int>();
public Human(string name, int age)
{
this.name = name;
this.age = age;
objectCount++;
Console.WriteLine($"{this.name}'s age is {this.age} and he has connected.");
nameAndAge.Add(name, age);
}
public static Dictionary<string, int> getNameAndAge()
{
return nameAndAge;
}
}Console.WriteLine($"{item.Key}: {item.Value}");Human bob = new Human("Bob", 18);
Human bobby = new Human("Bobby", 16);
Human bibby = new Human("Bibby", 11);
Console.WriteLine(Human.objectCount);
int length_of_objectCount = Human.objectCount;
for (int iterator = 0; iterator > length_of_objectCount; iterator++)
{
Console.WriteLine(Human.nameAndAge);
}
Console.ReadLine();
class Human
{
private string name { get; set; }
private int age { get; set; }
public static int objectCount;
static Dictionary<string, int> nameAndAge = new Dictionary<string, int>();
public Human(string name, int age)
{
this.name = name;
this.age = age;
objectCount++;
Console.WriteLine($"{this.name}'s age is {this.age} and he has connected.");
nameAndAge.Add(name, age);
}
public static Dictionary<string, int> getNameAndAge()
{
return nameAndAge;
}
}int length_of_objectCount = Human.objectCount;
for (int iterator = 0; iterator > length_of_objectCount; iterator++)
{
Console.WriteLine(Human.nameAndAge);
}