Func.blank1 недоступен из-за его уровня защиты - C#
Формулировка задачи:
Вопрос.
из-за чего ошибка?
Пишу на MVS 2010 C#
Есть два файла. Библиотека DLL ("func.dll") и основная программа. Класс blank1.
библиотека:
Основная программа:
При компиляции выдает:
"func.blank1" недоступен из-за его уровня защиты
В чем причина понять не могу. Из-за этого не работают и функции.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace func
{
class blank1
{
public int Nt;
public string nb;
public double cena;
public void vvod()
{
Console.WriteLine("Введите номер стола\n");
// Nt = Convert.ToInt32(Console.ReadLine());
bool NT = int.TryParse(Console.ReadLine(), out Nt);
if (!NT)
{
Console.Clear();
Console.WriteLine("Не верный ввод данных!\n Завершить программу?\nд-(Да)/Enter- продолжить");
string e = Console.ReadLine();
if (e == "д") Environment.Exit(0);
}
Console.WriteLine("Введите Название блюда\n");
nb = Console.ReadLine();
Console.WriteLine("Введите цену\n");
//cena = Convert.ToDouble(Console.ReadLine());
bool Cena = double.TryParse(Console.ReadLine(), out cena);
if (!Cena)
{
Console.Clear();
Console.WriteLine("Не верный ввод данных!\n Завершить программу?\nд-(Да)/Enter- продолжить");
string e = Console.ReadLine();
if (e == "д") Environment.Exit(0);
}
}
public void vivod()
{
Console.WriteLine("№Стола | Блюдо | цена\n");
Console.WriteLine(Nt + " " + nb + " " + cena);
}
public void TextFile()
{
StreamWriter file = new StreamWriter(@"D:\text.txt", true);
file.WriteLine("№Номер стола |Название |Цена ");
file.Write(Nt);
file.Write(" ");
file.Write(nb);
file.Write(" ");
file.WriteLine(cena);
file.Close();
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using func;
namespace func_dll
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Введите число заказов\n");
int n;
bool N = int.TryParse(Console.ReadLine(), out n);
// int n = Convert.ToInt32(Console.ReadLine());
if (!N)
{
Console.WriteLine("Не верный ввод. Перезапустите программу!\n");
Console.ReadLine();
Environment.Exit(0);
}
blank1[] s = new blank1[n];
for (int i = 0; i < n; i++)
{
s[i].vvod();
}
for (int i = 0; i < n; i++)
{
s[i].vivod();
}
string key;
Console.WriteLine("Записать в файл? д-(Да)/Enter-Нет\n");
key = Console.ReadLine();
if (key == "д")
{
for (int i = 0; i < n; i++)
{
s[i].TextFile();
}
}
else
{
Console.Clear();
Console.WriteLine("Для завершения программы нажмите клавишу Enter \n");
Console.ReadLine();
}
}
}
}Решение задачи: «Func.blank1 недоступен из-за его уровня защиты»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using func;
namespace func_dll
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Введите число заказов\n");
int n;
bool N = int.TryParse(Console.ReadLine(), out n);
// int n = Convert.ToInt32(Console.ReadLine());
if (!N)
{
Console.WriteLine("Не верный ввод. Перезапустите программу!\n");
Console.ReadLine();
Environment.Exit(0);
}
blank1[] s = new blank1[n];
for (int i = 0; i < n; i++)
{
s[i] = new blank1();//Инициализация элементов массива. Иначе все элементы будут равны NULL
//Это приведет к ошибке
s[i].vvod();
}
for (int i = 0; i < n; i++)
{
s[i].vivod();
}
string key;
Console.WriteLine("Записать в файл? д-(Да)/Enter-Нет\n");
key = Console.ReadLine();
if (key == "д")
{
for (int i = 0; i < n; i++)
{
s[i].TextFile();
}
}
else
{
Console.Clear();
Console.WriteLine("Для завершения программы нажмите клавишу Enter \n");
Console.ReadLine();
}
}
}
}