How can I call GetJsonList if I put it in a separate class?
For example, in my project I have a folder called Classes and that's where I have other classes and when I put this class there it tells me "Inconsistent accessibility: property type 'NameMyClass' is less accessible than property 'data'".
I have to use these variables in another part of my project and I don't want to overwrite my variables; if not call them from my folder called Classes.
public class GetJsonList
{
public string dato1{ get; set; }
public string dato2 { get; set; }
public string dato3 { get; set; }
}
public class RootListObject
{
public string resultado { get; set; }
public string mensaje { get; set; }
public GetJsonList datos { get; set; }//aqui me marca el error cuando esta en la carpeta llamada Clases.
}
In this way I deserialize the Json that I receive
var msjdes = JsonConvert.DeserializeObject<RootListObject>(miJsonFormat);
This is how I assign the data to my texbox:
text1.Text = msjdes.datos.Dato1;
text2.Text = msjdes.datos.Dato2;
text3.Text = msjdes.datos.Dato3;
Let's say your project structure is as follows:
In Class1.cs you have your classes:
In the class where you want to use the classes from your Classes folder you have to import your Classes folder to be able to use them:
So there is no problem with displaying the information:
My classes are Public and I use them inside a private class when calling them.