Reputation: 5
I have two forms in a Windows Forms project: Form1
and aCurso
.
I'm trying to send a List with objects of a class called curso
(I mean: List<curso>
) from Form1
to aCurso
.
But Visual Studio show this:
Accessibility inconsistency: The type of parameter
List<curso>
is less accessible than the methodaCurso.aCurso(List<curso>)
.
So, here is the code from Form1
:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _18_05_18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<curso> cursos = new List<curso>();
private void btnAC_Click(object sender, EventArgs e)
{
Form f = new aCurso(cursos);
f.Show();
}
}
}
aCurso
:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _18_05_18
{
public partial class aCurso : Form
{
List<curso> cursos = new List<curso>();
public aCurso(List<curso> cursos)
{
InitializeComponent();
this.cursos = cursos;
}
}
}
curso
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _18_05_18
{
class curso
{
private string nombre;
public curso(string nombre)
{
this.nombre = nombre;
}
}
}
Upvotes: 0
Views: 45
Reputation: 1277
You cannot expose a public method signature where some of the parameter types of the signature are not public. It wouldn't be possible to call the method from outside since the caller couldn't construct the parameters required.
All you have to do is make curso
class public
public class curso
{
private string nombre;
public curso(string nombre)
{
this.nombre = nombre;
}
}
Upvotes: 1