Misu Costel Misu Costel - 1 month ago 11
C# Question

Field type is less accessible than field

I have the following declarations:

public static class Helper
{
public static Func<T1,T2, string> myFunc = (t1, t2) =>
{
var result = string.Empty
//do some things with params t1 and t2, and build a string
return result
};
}


and I am consuming it like this:

var myString = Helper.myFunc(t1, t2);


in a different class.
It does not compile, it says "Inconsistent accesibility: field type ... is less accessible than field Helper.myFunc"
I understand that it has to do with the anonymus declaration, but how can it be solved?

Answer

Check that T1 and T2 also accessible in this code

var myString = Helper.myFunc(t1, t2);
Comments