I have below code
using System;
using System.Collections.Generic;
class Program {
static void add(Dictionary<string,string> hello){
hello = new Dictionary<string,string>();
hello["hello"] = "hello";
}
static void Main(string[] args) {
Employee employee = new Employee(); // Employee class
add(employee.hello); // employee.hello is property like public Dictionary<string,string> hello {get;set;}
Console.WriteLine(hello["hello"]);
}
}
I have also tried using ref
but i'm getting A property or indexer may not be passed as ref
When I intialize hello
this program works fine but when i try to intialize it in function it is giving me null reference error. So is there any way to initialize dictionary by passing through a function like that ?